473,322 Members | 1,719 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Getting IE6 to auto-select an item in a dropdown [jQuery]

On this page (just a demo) I can’t get IE6 to auto-select the first item
in the dynamically-generated drop-down menus. Well, that isn’t entirely
true. Sometimes it works properly, but never on the first try. When it
fails, the error message it gives is:

"Cannot set the selected property. Unspecified error."

FF2, IE7, and OP9 all behave as expected. I have tried a variety of
workarounds to no avail. I don't have an exhaustive list of everything I
have tried, but it seems like I have tried a hundred ways of setting the
"selected" attribute.

The page uses jQuery 1.1.2. Currently the page is using...

$("#select-how option:first-child").attr("selected","selected");

....to auto-select the first item in the list.

Can anybody offer me some clues?

--Mr. Wilson
Mar 21 '07 #1
4 5468
Mr. Wilson said the following on 3/21/2007 1:34 PM:
On this page (just a demo) I can’t get IE6 to auto-select the first item
in the dynamically-generated drop-down menus. Well, that isn’t entirely
true. Sometimes it works properly, but never on the first try. When it
fails, the error message it gives is:

"Cannot set the selected property. Unspecified error."

FF2, IE7, and OP9 all behave as expected. I have tried a variety of
workarounds to no avail. I don't have an exhaustive list of everything I
have tried, but it seems like I have tried a hundred ways of setting the
"selected" attribute.

The page uses jQuery 1.1.2. Currently the page is using...

$("#select-how option:first-child").attr("selected","selected");

...to auto-select the first item in the list.

Can anybody offer me some clues?
The first place to start would be a jQuery help site or group.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Mar 21 '07 #2
On Mar 22, 3:34 am, "Mr. Wilson" <mrwil...@625elmstreet.infowrote:
On this page (just a demo) I can't get IE6 to auto-select the first item
in the dynamically-generated drop-down menus. Well, that isn't entirely
true. Sometimes it works properly, but never on the first try. When it
fails, the error message it gives is:

"Cannot set the selected property. Unspecified error."
Set the selected and defaultSelected attributes of the first option
when you create the list. No further action required.

--
Rob

Mar 21 '07 #3
"Mr. Wilson" <mr******@625elmstreet.infowrote in message
news:et**********@unlnews.unl.edu...
On this page (just a demo) I can’t get IE6 to auto-select the first item in the
dynamically-generated drop-down menus. Well, that isn’t entirely true. Sometimes it
works properly, but never on the first try. When it fails, the error message it gives
is:

"Cannot set the selected property. Unspecified error."

FF2, IE7, and OP9 all behave as expected. I have tried a variety of workarounds to no
avail. I don't have an exhaustive list of everything I have tried, but it seems like I
have tried a hundred ways of setting the "selected" attribute.

The page uses jQuery 1.1.2. Currently the page is using...

$("#select-how option:first-child").attr("selected","selected");

...to auto-select the first item in the list.

Can anybody offer me some clues?
You do realize the default selection in most cases is the first element, therefore the
first-child?

I tested last-child, for example, in Internet Explorer 6 using jQuery 1.1.2 with no issue
or complaint. The last option of my select list was chosen by default.

-Lost
Mar 22 '07 #4
On Mar 22, 6:12 pm, "-Lost" <missed-s...@comcast.netwrote:
[...]
You do realize the default selection in most cases is the first element,
In practice, yes. But it is only convention to do so - the HTML
specification doesn't reqire it. It is good practice (though rarely
done) to ensure one option has the 'selected' attribute set.

If no option has its selected attribute set, Safari will not reset it
when the form's reset method is called either by script or using a
reset button.

therefore the first-child?
In some browsers, a select's firstChild might be a text node. I'm no
expert on jQuery, but it seems to skip text nodes when searching for
decendants - which might be a good thing sometimes but not others.

Responses here should focus on generic javascript and DOM, not a
particular implementation or library.
--
Rob

Mar 22 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Lew | last post by:
Hi all, I'm trying to create a page that has a user-selectable page auto-refresh option (IE 5.5). Essentially, it's a page that contains a checkbox, when the user checks the checkbox, I'd like...
5
by: Robert Downes | last post by:
I'm using the following in a page that I'm testing in Mozilla: p.actionLinkBlock {border: 1px #000000 dashed; padding: 0.2cm; width: auto} But the dashed border is extending to the right-edge...
0
by: Steve Barker | last post by:
Hi guys! In Visual Studio .NET, I like to enable auto-generation of XML documentation on the project properties screen, by adding an XML file name under "Configuration Properties" --> "Build"...
3
by: Jonathan | last post by:
Hi all: I originally posted this in an HTML forum, but have realized that the solution may (a) require a server-side change or (b) be non-existent. In any case, since the page I'm dealing with is...
5
by: Geoff Cayzer | last post by:
At http://www.blueclaw-db.com/tips_tricks.htm I came across a section which is included below and was hoping for some comment on the article. -------------- Almost never use this auto-number...
0
by: Alex Moskalyuk | last post by:
I am using System.Windows.Forms.TextBox to publish some real-time data that's coming off the external devices. My data is fed into the TextBox with proper precautions not to exceed the MaxSize...
1
by: Jason Galvin | last post by:
I would like to disable the auto-populating feature (remembers form element text between post-backs) when creating a .NET form. I have succeeded in disabling auto-populate by creating my controls...
13
by: S.Dickson | last post by:
I had an access database that i use as an ordering system. I have a form for entering customer details. When i add a new customer on the form the customer number is an auto number that appears when...
1
by: MRamaLakshmi | last post by:
hi, I am developing an application using Java Applet which will be uploading files. Its throwing Null Pointer exception while detecting the proxy when we are trying to load the applet using Java6....
2
by: Piotr K | last post by:
Hi, I've encountered a strange problem with Firefox which I don't have any idea how to resolve. To the point: I've <divelement with a style "height: auto" and I want to retrieve this value...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.