Friday, 9 August 2013

How to remove an option in javascript?

How to remove an option in javascript?

I do not understand why this is not working? And not removing the small
option!
I have the script:
<script>
var quantity_in_stock_s = 0
if ( quantity_in_stock_s === 0)
{
var S = document.getElementById("S");
document.getElementById("mySelect").removeChild(S);
}
</script>
and the HTML:
<form>
<select id="mySelect">
<option id="S">Small</option>
<option id="M">Medium</option>
<option id="L">Large</option>
</select>
</form>

No comments:

Post a Comment