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 :: random password javascript 
Javascript :: how to know memory used in localstorage javascript 
Javascript :: sequelize like search 
Javascript :: remove last 3 characters from string javascript 
Javascript :: split string by uppercase javascript 
Javascript :: javascript count occurrences of letter in string 
Javascript :: scoll a div to bottom in angular 
Javascript :: how to connect frontend with solidity 
Javascript :: javascript replace part of string 
Javascript :: javascript get body height 
Javascript :: regex do not contain 
Javascript :: javascript remove get parameter from url 
Javascript :: jquery get all checked checkboxes 
Javascript :: onEnter input field react 
Javascript :: javascript change web page title 
Javascript :: Node.js: printing to console without a trailing newline 
Javascript :: generates a random rgb color number. 
Javascript :: NullInjectorError: R3InjectorError(DashboardModule)[DatabaseService - DatabaseService - HttpClient 
Javascript :: angular viewchild input element value 
Javascript :: javascript detect space in string 
Javascript :: jquery how to know if element is visible 
Javascript :: create button inside td tag javascript 
Javascript :: how to get random boolean in javascript 
Javascript :: remove div javascript 
Javascript :: d3.js clear svg 
Javascript :: javascript timestamp to relative time 
Javascript :: int to string js 
Javascript :: javascript hashtable contains key 
Javascript :: javascript check if undefined or null 
Javascript :: fetch with bearer token 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =