|
From: Vijay N. <VNa...@ma...> - 2003-12-22 18:04:55
|
I wrote:
>> I am having difficulties using HtmlSelect for simulating the following
>> dropdown menu.
>>
>> The Options have no Value.
>>
>> <SELECT NAME="MAXDOCS">
>> <OPTION >25
>> <OPTION SELECTED>50
>> <OPTION >100
>> <OPTION >250
>> <OPTION >500
>> </SELECT>
>> How to select the desired Option?
>
Mike Bowler wrote:
> How do you expect to actually use this select if there are no values
> set
> in the options? Nothing will get sent back to the server.
> HtmlUnit assumes that all options will have a value attribute (they're
> pretty useless without).
No, this assumption is not correct. The HTML 4.0 specification states:
"""
OPTION Attribute definitions
selected [CI]
When set, this boolean attribute specifies that this option is
pre-selected.
value = cdata [CS]
This attribute specifies the initial value of the control. If this
attribute is not set, the initial value is set to the contents of the
OPTION element.
label = text [CS]
This attribute allows authors to specify a shorter label for an option
than the content of the OPTION element. When specified, user agents
should use the value of this attribute rather than the content of the
OPTION element as the option label.
"""
http://www.w3.org/TR/html401/interact/forms.html#h-17.6
It's that section about "If the attribute is not set, the initial value
is set to the contents of the OPTION element" that directly applies to
the current situation here. I did a quick test case with HttpUnit, and
that library handles this correctly. I think HtmlUnit's handling of this is
incorrect.
|