<ns*******@hotmail.com> wrote in message
news:i1********************************@4ax.com...
Hi
I need to clear the contents of a pulldown and then load new contents
into it. Is this possible in Javascript? If so how?
Thanks
Nick Steele
Yes it's possible :o)
something like this you'r looking for ?
<script type="text/javascript">
newOpt = []; //array with new values
newOpt[0] = "newVal1"
newOpt[1] = "newVal2"
newOpt[2] = "newVal3"
newOpt[3] = "newVal4"
function changeOpt(){
opt = document.frm.whee.options
for(var i=0;i<newOpt.length;i++){
opt[i]=new Option(newOpt[i],newOpt[i]);
}
for(i=i;i<opt.length;i++)
opt[i]=null
}
</script>
<form name="frm">
<select name="whee">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</form>
<a href="#" onclick="changeOpt();return false">Newvalue</a>
Best Regards
Nick