Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JavaScriptQuestions plz solve my query?
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


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


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


Advertisement
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 Tutorials/Questions & Answers:
Advertisements
Advertisements
 

 

 

DMCA.com