I want to remove all items in a drop down list, surely this is possible in
one operation?
All I can find is to set every option in the list = null
Well, not exactly all in one operation...
This works in newer browsers only (IE5+, NN6+, Mozilla, Opera, etc). If
you have to support older browsers (NN4), I believe you're stuck with
setting them to null.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"
http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title> New Document </title>
<script type="text/javascript">
function removeChildren(s)
{
while (s.hasChildNodes())
s.removeChild(s.childNodes[0]);
}
</script>
</head>
<body>
<form name="f1">
<select name="s1">
<option value="0">-- choose one --</option>
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
</select>
<input type="button" value="remove options" onClick="removeChildren
(this.form.elements['s1']);">
</form>
</body>
</html>
--
--
~kaeli~
God was my co-pilot... but then we crashed in the mountains
and I had to eat him.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace