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 date to string format 
Javascript :: window closing event js 
Javascript :: formik clear field 
Javascript :: create textbox using javascript 
Javascript :: add variable numerically in javascript 
Javascript :: string to int js 
Javascript :: javascript iterate over chars in string 
Javascript :: js date now format 
Javascript :: jquery key enter events 
Javascript :: first day of month and last day of month moment js 
Javascript :: express limit based on ip 
Javascript :: cypress display timestamp in milliseconds 
Javascript :: redux useselector 
Javascript :: loadash sort by order of another array 
Javascript :: make select option selected javascript 
Javascript :: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project electronicbookshop: Compilation failure 
Javascript :: jquery addeventlistener 
Javascript :: mui how to set background in theme 
Javascript :: adding media queries in makeStyle material react 
Javascript :: splidejs pauseOnHover 
Javascript :: react, scroll element into view 
Javascript :: cypress have attribute 
Javascript :: bottom tab navigator react native transparent 
Javascript :: replace url without reload js 
Javascript :: lodash remove undefined values from array 
Javascript :: pymongo add json to collection 
Javascript :: new create react app 
Javascript :: letter javascript regex 
Javascript :: js focus textarea 
Javascript :: destructure dynamic properties 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =