Bug Tracker

Ticket #3226 (new bug)

Opened 1 month ago

Last modified 1 month ago

val() and val(string) do not work with SELECTs in IE6

Reported by: JPLosier Assigned to: anonymous
Type: bug Priority: major
Milestone: 1.3 Component: core
Version: 1.2.6 Keywords: select, option, val
Cc: Needs: Review

Description

I know; I hate IE too. But from looking at the jQuery source, it looks like you're setting or returning the VALUE of the SELECT, but that's not the DOM standard. Nice browsers like Firefox know what you mean, but IE isn't so helpful. The DOM standard uses the collection of options and the selectedIndex.

Here's some (non-jQuery) code to show what I mean:

function setSelect(strSelectID, newValue) {

var objSelect = document.getElementById(strSelectID);

if (objSelect) {

for (var i=0; i<objSelect.length; i++) {

if (objSelect.options[i].value == newValue) objSelect.selectedIndex = i;

}; // for i

}; // if SELECT exists

}; // setSelect()

function getSelectedValue(strSelectID) {

var objSelect = document.getElementById(strSelectID); return objSelect.options[objSelect.selectedIndex].value;

}; // getSelectedValue()

My example code does not handle multi-select, but that is a matter of manipulating the SELECTED attribute of the OPTION. If you have any questions, feel free to contact me. I hope this helps make jQuery an even better product than it is now. Keep up the great work!

Attachments

Change History

Changed 1 month ago by flesler

Is this actually causing any problem ? Can you provide a test case where something fails ?

Note: See TracTickets for help on using tickets.