[thelist] Deselecting a select element in JS
Warden, Matt
mwarden at mattwarden.com
Thu Mar 21 13:59:00 CST 2002
On Mar 21, Hardacker, Andrew had something to say about RE: [thelist]...
>This works in Netscape6, but not IE. What's wrong?
>
><script type="text/javascript">
>function deselect() {
> var s = document.getElementById('s');
> alert("before: selected="+s.selectedIndex);
> for (var i=0;i < s.length; i++) {
> s.options[i].selected = false;
> }
> alert("after: selected="+s.selectedIndex);
>}
></script>
i remember a bug with looping through options. i was setting the options
themslves to null, but it may be the same bug here.
try initializing i=s.length, then decrementing it until it's 0
in other words, go backwards, rather than forwards like you're doing.
that was the workaround.
let us know if it helps here too
thanks,
--
mattwarden
mattwarden.com
More information about the thelist
mailing list