Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9168039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:32:11+00:00 2026-06-17T15:32:11+00:00

I have a select element on my HTML page. I want to populate it

  • 0

I have a select element on my HTML page. I want to populate it with an array. as we can give an array as dataprovider to comboBox in action script. I do the following

in HTML…

<table>
  <tr>
    <td>
      <label>Recording Mode:</label>
    </td>
    <td>
      <select id="rec_mode">        
      </select>
    </td>
  </tr>
</table>

in javascript…

var videoSrcArr = new Array("option1", "option2", "option3", "option4", "option5");

how can I populate rec_mode element when page is loaded with VideoSrcArr? Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:32:12+00:00Added an answer on June 17, 2026 at 3:32 pm

    I highly recommend you use a format like the following:

    var options =
    [
      {
        "text"  : "Option 1",
        "value" : "Value 1"
      },
      {
        "text"     : "Option 2",
        "value"    : "Value 2",
        "selected" : true
      },
      {
        "text"  : "Option 3",
        "value" : "Value 3"
      }
    ];
    
    var selectBox = document.getElementById('rec_mode');
    
    for(var i = 0, l = options.length; i < l; i++){
      var option = options[i];
      selectBox.options.add( new Option(option.text, option.value, option.selected) );
    }
    

    You don’t run in to the problem of having to select a default option and you can easily generate the options array dynamically.

    — UPDATE —

    ES6 version of the above code:

    let optionList = document.getElementById('rec_mode').options;
    let options = [
      {
        text: 'Option 1',
        value: 'Value 1'
      },
      {
        text: 'Option 2',
        value: 'Value 2',
        selected: true
      },
      {
        text: 'Option 3',
        value: 'Value 3'
      }
    ];
    
    options.forEach(option =>
      optionList.add(
        new Option(option.text, option.value, option.selected)
      )
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have a <select> element on my HTML page, and I want to
i have a following scenario in my html page i want to select the
I have a html combo/select. When the user selects a element, I want to
I have n number of select elements in an html page that are used
I have a html element (like select box input field) in a table. Now
I have a table. In this table have select element. How can I find
I have a number of CheckBox elements in my html page. What I want
I want to have the same functionality of select in HTML but using div
I have an HTML page which contains: a <select> dropdown with 3 options with
So, here's the deal. I have an html table that I want to populate.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.