UmarAbbasKhan UmarAbbasKhan - 1 year ago 70
Javascript Question

How can I populate more than one select elements with one javascript function?

I have following html:


<select id="options" title="options" name="options"></select><br/>
<select id="options1" title="options" name="options"></select><br/>
<select id="options2" title="options" name="options"></select><br/>

And I have a javascript function which finds data from database using jquery ajax for these select elements. How can I place that data in all these select elements at the same time?

Answer Source

Assuming options is a list of <option> elements that came from the server or was built with data coming back from the server:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download