html initialize select
<select>
<option value="" selected disabled hidden>Choose here</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
<option value="4">Four</option>
<option value="5">Five</option>
</select><option selected>
5
</option>//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]);
}
Also in JavaScript:
- see if discord message is in dm discord.js
- delay in javascript
- dynamic forms in react
- how to get timestamp in javascript of a date object
- javascript get element width and height
- js extract all tags not have attr
- toggle element javascript
- inmutabilidad javascript
- js check if number has decimals
- how can when click buton scrool to another elemtn
- perl json response to list all the files in a directory
- jquery each has class
- moment js date between two dates
- create dynamic fields in react
- emmet react self closing tags
- email id validation in javascript
- js static methods
- object to array javascript
- resellerclub api with react js
- how to split two digit number in javascript
- what does json.parse do
- append after javascript
- js loop trough map
- javascript for loop starting from end