Skip to main content

Bug Tracker

Side navigation

#2551 closed bug (fixed)

Opened March 19, 2008 03:23AM UTC

Closed February 10, 2011 10:52PM UTC

Last modified March 13, 2012 01:58PM UTC

val() failed after reset form in ie6/ie7

Reported by: diyism Owned by: rwaldron
Priority: low Milestone: 1.5.1
Component: attributes Version: 1.5
Keywords: val() failed after reset form in ie6/ie7 Cc:
Blocked by: Blocking:

Getting value with val() failed after reset form in ie6/ie7:

<form name="kk">
<select id="kkk">
        <option value="cf">cf</option>
        <option value="gf">gf</option>
<input type="button" onclick="mc()">
function mc()
Attachments (1)
  • index.html (2.1 KB) - added by tinyfly December 08, 2009 07:49PM UTC.

    Test case alerting the values returned from both jQuery and DOM methods

Change History (14)

Changed July 08, 2009 04:00PM UTC by mickyp comment:1

Is there any solution for this issue?

Is it truly a jQuery issue? or it's IE's issue.

I test in firefox and Google Chrome, there is no problem.

I test failed in IE6 and IE8...

Changed December 08, 2009 07:26PM UTC by tinyfly comment:2

Bug? I don't know but it is definitely an IE idiosyncrasy that jQuery could work around.

Here is how it works:

If you don't have a "selected" attribute on one of your options IE defaults to the first option and the DOM properties select.selectedIndex = 0 and option.selected = true.

However if you click an input type="reset" or run the reset method IE reports select.selectedIndex = 0 and option.selected = false.

I think this behavior is undesirable.

Before jQuery gets the value of the selected option it only checks for option.selected. Checking for option.selected || selectedIndex might be a way to get around this.

Changed December 10, 2009 04:07AM UTC by john comment:3


Duplicate: #4984

Changed June 20, 2010 06:00PM UTC by dmethvin comment:4

component: coreattributes

Changed November 07, 2010 12:25AM UTC by rwaldron comment:5

milestone: 1.41.5
priority: majorlow
resolution: → worksforme
status: newclosed

This bug no longer exists

Tested in IE6 & 7

Changed January 24, 2011 03:29PM UTC by scottgonzalez comment:6

resolution: worksforme
status: closedreopened

Replying to [comment:5 rwaldron]:

This bug no longer exists

Your test is invalid. You're checking the value inside the reset event before the form is reset.

Changed January 24, 2011 04:13PM UTC by shadedecho comment:7

I've filed this as a bug in the IE Connect feedback system:

The (non-jquery) test case I submitted to them is:

Scott noted that setting el.selectedIndex = el.selectedIndex seems to "reset" the options' values properly, so perhaps the jQuery workaround could be to just make that call (what seems like a no-op in all other browsers) right at the beginning of a call to .val() on a select.

Changed January 26, 2011 04:24PM UTC by shadedecho comment:8

_comment0: turns out the fix only needs to be applied to single-selects, and in fact if applied to multi-selects, breaks them. but the fix was as described, setting selectedIndex=selectedIndex. \ \ patch:

turns out the fix only needs to be applied to single-selects, and in fact if applied to multi-selects, breaks them. but the fix was as described, setting selectedIndex=selectedIndex.


Changed January 27, 2011 12:26PM UTC by jitter comment:9

owner: → shadedecho
status: reopenedassigned

Changed February 07, 2011 05:37PM UTC by jitter comment:10

owner: shadedechojitter
version: 1.5rc11.5

Changed February 10, 2011 10:41PM UTC by rwaldron comment:12

owner: jitterrwaldron

Changed February 10, 2011 10:52PM UTC by rwldrn comment:13

resolution: → fixed
status: assignedclosed

Make sure .val() works after form.reset() in IE. Fixes #2551.

Changeset: 43a41ba7ecef732b48dcfc930fa9df8835fc4944

Changed March 31, 2011 07:26PM UTC by comment:14

FYI - This still happens on IE6 w/ v1.5.1 - had to add browser detection and not have it try to set the value of a select list using "val()" but instead used some old style code to set the selected index. In IE6 this does not require a "reset" action. I don't even have one on my form.

Honestly not worth fixing in my opinion. I had to get help from someone else with an IE 6 browser just to find out what the problem was and add the work around.