I got a problem that how to dynamically populate values in html combo box using javascript. Or rather say, how to dynamically add options in select element of html.
here is our html code:
<select id="id_s"> <option value="a">first</option> <option value="b">second</option> </select>
Now suppose i want to add one option ‘third’, here is the code for it:
var combo = document.getElementById('id_s'); combo.options[2] = new Option ("third", "c");
Courtesy : This forum.
Advertisements
What kind of twat designs a webpage with white text on a yellow background!?
thanks for bringing my attention, this happened due to changing of theme.