I have the following in the page
<select name="val" size="1" >
<option value="A">Apple</option>
<option value="C">Cars</option>
<option value="H">Honda</option>
<option value="F">Fiat</option>
<option value="I">Indigo</option>
</select>
I would like to remove certain values from my select if certain conditions are true.
E.g
if(frm.product.value=="F"){
// remove Apple and Cars from the select list
}
How can I do this using javascript
Alternatively you can also accomplish this with getElementsByName
So in matching on the option value of "C" we could remove Cars from the list.
You have to go to its parent and remove it from there in javascript.
"Javascript won't let an element commit suicide, but it does permit infanticide"..:)
try this,
This should do it
Check the fiddle here