OZONE Asylum
Forums
DHTML/Javascript
Moving an <option> to the bloody top in IE
This page's ID:
30735
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
My client asked me (a js client side programmer) to change the order of the options so that their company's option appears at the top of a select box when the page loads. The following code works in FF but fails in IE7 when I try to swap two options: [code] function load{ var shippingLocation = document.getElementById("location"); var swap = null; var initiallyFirstItem = shippingLocation.options[0].cloneNode(true); var lastPos = null; for(var i = 0; i < shippingLocation.length; i++) { if(shippingLocation.options[i].value == "XETEX") { swap = shippingLocation.options[i]; lastPos = i; break; } } console.debug("sl: " + shippingLocation.options[0]); console.debug("s: " + swap); shippingLocation.options[0] = swap; shippingLocation.options[lastPos] = initiallyFirstItem; shippingLocation.selectedIndex = 0; } [/code] I get an error on the next to the third line from the bottom: shippingLocation.options[0] = swap; The error states that "object doesn't support this property or method". What's IE's beef with switching option items? [IMG]http://i9.photobucket.com/albums/a58/Maskkkk/maskkkkaroni.png[/IMG] - AIM: MASKKKK [url=http://nickciske.com/tools/binary.php] 01001101011000010111001101101011011010110110101101101011[/url]
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »