Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

add select option javascript

var min = 12,
    max = 100,
    select = document.getElementById('selectElementId');

for (var i = min; i<=max; i++){
    var opt = document.createElement('option');
    opt.value = i;
    opt.innerHTML = i;
    select.appendChild(opt);
}
Comment

select add option js

//add one option
let select = document.getElementById('mySelect');
let option = document.createElement('option');

option.value = 1;
option.text = 'option 1';   
select.add(option);


//Add few option , exemple from Json 'items'
for (const key in items) {
  if (Object.hasOwnProperty.call(items, key)) {
    const item = items[key];

    let option 		= document.createElement('option'); // again init option

    option.value 		= item.id;
    option.text 		= item.name;

    select.add(option);
  }
}
Comment

add select option javascript


var min = 12,
    max = 100,
    select = document.getElementById('selectElementId');

for (var i = min; i<=max; i++){
    var opt = document.createElement('option');
    opt.value = i;
    opt.innerHTML = i;
    select.appendChild(opt);
}

Comment

PREVIOUS NEXT
Code Example
Javascript :: Javascript switch case code format 
Javascript :: parse local json file 
Javascript :: responsive grid using antd 
Javascript :: js find first line break in string 
Javascript :: convert to datetime in jquery 
Javascript :: string to in js 
Javascript :: jquery unbind event 
Javascript :: how to parse json in java 
Javascript :: reload table jquery 
Javascript :: moment month start date and end date 
Javascript :: javascript transpose rows to columns 
Javascript :: js get date in yyyy-mm-dd 
Javascript :: javascript parsefloat() method 
Javascript :: javascript xmldocument to string 
Javascript :: makes number negative javascript 
Javascript :: inline style jsx 
Javascript :: tailwind modal react 
Javascript :: react check if in mobile 
Javascript :: moment day in range 
Javascript :: copy dict js 
Javascript :: angular access form control value 
Javascript :: express send 401 response 
Javascript :: keypress javascript 
Javascript :: sum of n numbers in javascript 
Javascript :: devtools failed to load sourcemap when debugging react native 
Javascript :: discord.js pick random from array 
Javascript :: usenavigate react router dom v6 
Javascript :: this is a problem related to network connectivity npm 
Javascript :: jquery capture tab 
Javascript :: destructuring dynamic properties 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =