select default value
<option selected>
5
</option>
html initialize select
//html
//<select name="sel" id="sel></select>
//js
//generating options
let sel = document.getElementbyID('sel');
let opt = ['option1', 'option2', 'option3'];
for(let idx=0; idx<opt.length; idx++){
sel.options[idx] = new Option(opt[idx], opt[idx]); //new Option("Text", "Value")
}
//init
for(let idx=0; idx<sel.length; idx++){
sel.options[idx] = undefined;
}
//generating other options
let opt2 = ['optA', 'optB', 'optC'];
for(let idx=0; idx<opt2.length; idx++){
sel.options[idx] = new Option(opt2[idx], opt2[idx]);
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us