Click to See Complete Forum and Search --> : Clear a select control List


locus86
March 4th, 2003, 03:18 AM
I have 3 radio buttons and 1 select control.

The select control is populated depending on which radio button is checked.

When a radio button is clicked, I call a function that will clear the select control and polutate it again with a new list of elements.

However, I am not able to clear all the elements properly.

Is there any way I can clear all the elements in a select control at one go???

Thanks

antares686
March 4th, 2003, 05:46 AM
The fastest way to clear the list is to set the innerHTML of the Select to ''. This will wipe out all options within.

Ex.


<select name=bob>
<option value=1>t1
<option value=2>t2
<option value=3>t3
<option value=4>t4
</select>

<input type=button name=X value=Clear OnClick="javascript:bob.innerHTML = ''">