Home Answers Viewqa JavaScriptQuestions plz solve my query?

 
 


Ali Ahmad
plz solve my query?
1 Answer(s)      2 years and 3 months ago
Posted in : JavaScript Questions

how to remove all the options from select control in html using java script?

View Answers

February 22, 2011 at 11:51 AM


JavaScript remove all items

<html>
<script language="javascript" >

function removeAllItems(selectbox)
{
var i;
for(i=selectbox.options.length-1;i>=0;i--)
{
selectbox.remove(i);
}
}
</script>
<form name="list">
<select id="item" NAME="item">
<option value="one">One</option>
<option value="two">two</option>
<option value="three">three</option>
<option value="four">four</option>
<option value="five">five</option>
</select>
<br>
<input type="button" value="Remove All Item" onClick="removeAllItems(item);">
</form>
</html>









Related Pages:

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.