Bug Tracker

Ticket #440 (closed bug: worksforme)

Opened 8 years ago

Last modified 8 years ago

Getting value for option element with no value attribute set (IE)

Reported by: joern Owned by:
Priority: major Milestone:
Component: core Version:
Keywords: Cc:
Blocking: Blocked by:


If we declare a combo box in a form without the value attribute we can´t get the value in internet Explorer.


<select id="combo" name="combo">
<option selected>3</option>


This doesn´t work on ie.

We must declare the select with the attribute value:

<select id="combo" name="combo">
<option value="1">1</option>
<option value="2">2</option>
<option value="3" selected>3</option>


This works now on ie.

Could be it´s a bug. I only wanted to notice the jquery team. Thanks for reading.

It's a good question if this is a bug or not. If I remember it correctly, the value of an option element should be it's text content if the value attribute isn't set. In that case, it should be possible for jQuery to handle it, that is, check if the value attribute exists and get the text if it doesn't.

Change History

comment:1 Changed 8 years ago by joern

  • Status changed from new to closed
  • Resolution set to wontfix

I don't think this can be fixed by jQuery. Consider this example:

<select id="combo" name="combo">
<option value="">Please select...</option>
<option value="2">2</option>
<option value="3">3</option>


Now if jQuery gets the text of the selected option element when the value is empty, it would return "Please select..." instead of an empty string, now quite what we want.

A decent check if the value attribute exists or not should be added to the formField method of the form plugin, not into core.

comment:2 Changed 8 years ago by aaron.heimli

I agree with Joern on this, especially if all of the shortcuts are getting removed from the core in 1.1

comment:3 Changed 8 years ago by bhb@…

  • Status changed from closed to reopened
  • Resolution wontfix deleted

I disagree and think that this should be fixed.

The *Bottom Line* is that IE submits a value of "b" for "combo" if the following select is left untouched.

<html><body> <form action="" method="GET">

<select name="s"> <option>a</option> <option SELECTED>b</option> <option>c</option> </select> <input type="submit">

</form> </body></html>

I think that jQuery's .val() should always reflect the value that gets SUBMITTED. What do you guys think?

comment:4 Changed 8 years ago by joern

  • Status changed from reopened to closed
  • Resolution set to worksforme

Aaron found a solution to this and Mike integrated it into the form plugin.

Note: See TracTickets for help on using tickets.