Bug 16753 - Select gives no option value if key.equals(value)
Summary: Select gives no option value if key.equals(value)
Status: RESOLVED INVALID
Alias: None
Product: Taglibs
Classification: Unclassified
Component: Input Taglib (show other bugs)
Version: unspecified
Hardware: Other other
: P3 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-02-04 11:08 UTC by Svefors
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments
Example of select in combination with javascript (974 bytes, text/html)
2003-02-05 09:59 UTC, Svefors
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Svefors 2003-02-04 11:08:39 UTC
Given a map o with the following values
Map o;
o.put("one", "1");
o.put("2", "2");

comes out in the html as
<option value="1">one</option>
<option>2</option>

Which is quite unhandy if you wish to submit the form...

I've looked at the sources and I am confused by the following code snippet:

private void outputOption(...){
...
if (!value.equals(key))
  out.print(" value=\"" + Util.quote(value) + "\"");
...

It looks very intentional so maybe I am missing some important aspect?
Comment 1 Svefors 2003-02-04 14:35:54 UTC
> Which is quite unhandy if you wish to submit the form...

correction on the submit part. That actually works fine. But I have to use
JavaScript.
Comment 2 Shawn Bayern 2003-02-04 17:04:18 UTC
Per the HTML standards, the value is equal to the key by default.  Are you 
experiencing behavior by some browser that suggests this isn't the case?
Comment 3 Svefors 2003-02-05 09:59:42 UTC
Created attachment 4737 [details]
Example of select in combination with javascript
Comment 4 Svefors 2003-02-05 10:12:34 UTC
You are correct that the value of the request parameter in the GET/POST of the
form will have the value of the label if no value exists.

However, the browser all work a little bit different when it comes to selects
and javascript.

document.frm.theSelect.value
Ne4: Allways returns null, even if there is a value
IE: Returns a value, not the label
Mozilla: Works like a charm!

document.frm.theSelect.options[document.frm.theSelect.selectedIndex].value
Ne4 and IE Returns a value, not the label
Mozilla: Works like a charm!

document.frm.theSelect.options[document.frm.theSelect.selectedIndex]
Always returns an object. Probably an option

Mozilla follows standard, IE 6.0.26 and Ne 4.79 do not.