struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Lowe <mark.l...@talk21.com>
Subject Re: Select without selected value
Date Wed, 24 Dec 2003 17:32:40 GMT
an option will only be selected by default if the form property has 
been set to a value or there is a match in an available scope (like a 
parameter with the same name as the form property). Otherwise it will 
just do its thing.

I'd use a simple action without a formbean for something like a 
navigation menu

<form action="<c:url value="/process.do" />" method="POST">
	<select name="id" ...
	
String id = request.getParameter("id").toString();
get the values out of the parameter map as you would with a plain old 
servlet.

but nothing wrong with using an action form, especially for consistency.

Cheers Mark


On 24 Dec 2003, at 17:08, Brice Ruth wrote:

> You could also do something like:
>
> <option></option>
>
> Which should give you something resembling no option being selected. 
> Beware, unless you have validation of this field, it is perfectly 
> valid for the browser to submit this ...
>
> Wendy Smoak wrote:
>
>>> -----Original Message-----
>>> I use select with multiple=false and I don't set the parameter's
>>> value. As result I get:
>>> <form name="faqForm" method="post" action="/dp/showFaq.do">
>>>        <select name="id" onchange="submit()">
>>>        <option value="1">Test1</option>
>>>        <option value="2">Test2</option>
>>>        </select>
>>> </form>
>>> So none of options has "selected" attribute, but first option is
>>> selected on the page.
>>>
>>
>> I think what you're trying to do is invalid HTML, and the browser is
>> "fixing" it for you by selecting the first element.  In a drop-down
>> select list, there's really no such thing as having none of the items
>> selected.  Whichever one is "visible" is selected.
>> If you need to have 'nothing' selected, how about a 'blank' element at
>> the top:
>>  <option value="">--Please choose one--</option>
>>
>> You may not be setting the value, but the form property exists, so it
>> DOES have a value-- null or the empty string, probably.
>>
>>
>
> -- 
> Brice D. Ruth
> Sr. IT Analyst
> Fiskars Brands, Inc.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message