Skip to main content

Bug Tracker

Side navigation

#2652 closed enhancement (fixed)

Opened April 04, 2008 03:17PM UTC

Closed July 23, 2008 05:00PM UTC

Last modified March 15, 2012 09:24AM UTC

val() returns an empty string in IE6/7

Reported by: kowcik Owned by: flesler
Priority: minor Milestone: 1.3
Component: core Version: 1.2.6
Keywords: val, select selected Cc:
Blocked by: Blocking:
Description

See the attached example.

Attachments (2)
  • val.html (0.8 KB) - added by kowcik April 04, 2008 03:17PM UTC.

    Test case from jQuery documentation

  • val[5790].diff (0.8 KB) - added by flesler July 22, 2008 04:18PM UTC.
Change History (6)

Changed May 16, 2008 06:44PM UTC by flesler comment:1

resolution: → invalid
status: newclosed

So.. the options don't have a 'value' attribute, it's expected that you get and empty string as return.

I'll close as invalid, but please reopen if you have anything else to say, do include more details when you do that (better test case and tell us what you expect the return to be, etc).

Changed May 22, 2008 11:14AM UTC by kowcik comment:2

resolution: invalid
status: closedreopened

In IE val() returns empty strings, whereas in Firefox the value is returned also when there's no value attributed. This should the desired behaviour, because val seems to be an abstraction to access inputs values as they would be submitted to the server. Also, there is a specific line in jQuery code that tries to retrieve values from options, but for some reason this value is not returned later. Generally option.text is the right property to read from in IE.

//val function source code

if ( option.selected ) {
// Get the specifc value for the option
value = jQuery.browser.msie && !option.attributes.value.specified ? option.text : option.value;

Changed May 22, 2008 06:40PM UTC by flesler comment:3

owner: → flesler
status: reopenednew

Changed May 22, 2008 06:40PM UTC by flesler comment:4

status: newassigned

Changed July 22, 2008 04:18PM UTC by flesler comment:5

milestone: 1.2.41.3
need: PatchCommit
priority: majorminor
type: bugenhancement
version: 1.2.31.2.6

val() is meant to be used on selects, not on options.

If you call it on a select, it will return the value of the selected options, or an array if it's "multiple".

Still.. I pulled out a patch, I'll ask for opinions to see if it should be applied or not.

Changed July 23, 2008 05:00PM UTC by flesler comment:6

resolution: → fixed
status: assignedclosed

Fixed and added some tests at [5793].