Forum Moderators: open

Message Too Old, No Replies

Remove Non-selected Options from Select Item?

javascript

         

rate

8:19 am on Apr 23, 2008 (gmt 0)

10+ Year Member



Hello,

I have a javascript question.

Let's say a user is presented with the following dropdown box and selects teh following item:

<select name="cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat">Fiat</option>
<option value="audi">Audi</option>
</select>

Is it possible for js to delete the unselected item on some event?

Thanks.

rate

10:10 am on Apr 23, 2008 (gmt 0)

10+ Year Member



Disregard the above post. I received answer in another forum.

coopster

7:50 pm on Apr 24, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, rate.

Glad you got it sorted. All you have to do is loop on the parentNodes children and removeChild node for those that don't match the selected value.