You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Vijay Kumar <vi...@hotmail.com> on 2002/08/02 16:08:58 UTC

Reading All the values from ListBox on Submit

Hi,
   Is there any to read all the values from Listbox on submit without 
selecting them. What i am looking for is on submit all the values should be 
read from ListBox and somehow pass it java. I can read all values on client 
side using javascript but is there any way to pass them to java.
Any example or code on it.
Thanks in Advance.

Cheers
vkvk


_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Reading All the values from ListBox on Submit

Posted by James Mitchell <jm...@telocity.com>.
Why don't you give us a use case and let someone help you get to a better
solution?

Nothing good will come from trying to use script to 're-capture' list
values....its a total hack job.

There's got to be a different approach to what you need.  Let's start at the
root of the problem.

What exactly are you wanting to do....pass around your drop down list in the
request instead of session or application scope?


James Mitchell
Software Engineer\Struts Evangelist
Struts-Atlanta, the "Open Minded Developer Network"
http://www.open-tools.org/struts-atlanta




> -----Original Message-----
> From: Rajesh Kalluri [mailto:rkalluri@manduca.com]
> Sent: Friday, August 02, 2002 10:34 AM
> To: Struts Users Mailing List
> Subject: RE: Reading All the values from ListBox on Submit
>
>
> Vijay,
>
> I am assuming you are trying to do this with struts, you can also do this
> the non-struts way in a similar fashion.
>
> 1)Here is a snippet of a jsp with a  select box with multiple="true".
>
> <html:select property="selected" multiple="true" size="8">
> 	<html:options collection="cajas" property="articleId"
> labelProperty="title"/>
> </html:select>
>
> 2) Here is the submit button which will select all values in your
> select box
> submits the form (it is the equivalent of user selecting all values.
>
> 	<html:submit property="validate"
> onclick="selectAll(selected);return
> true;"/>
>
> 3)The java script function used by the onclick button.
>
> <script language="JavaScript">
> function selectAll( )
> {
> for( j=0; j<selectAll.arguments.length; j++ )
>   {
>   col1 = selectAll.arguments[j];
>   for(i=0; i<col1.options.length; i++ )
>     {
> 	col1.options[ i ].selected = true;
> 	}
>   } // end loop
>   return true;
> }
> </script>
>
> 4)In your action you can retreive your form bean which has a properties
> string[] with the users selection....
>
> HTH
> Rajesh
>
> -----Original Message-----
> From: Vijay Kumar [mailto:vijay_vkvk@hotmail.com]
> Sent: Friday, August 02, 2002 10:09 AM
> To: struts-user@jakarta.apache.org
> Subject: Reading All the values from ListBox on Submit
>
>
> Hi,
>    Is there any to read all the values from Listbox on submit without
> selecting them. What i am looking for is on submit all the values
> should be
> read from ListBox and somehow pass it java. I can read all values
> on client
> side using javascript but is there any way to pass them to java.
> Any example or code on it.
> Thanks in Advance.
>
> Cheers
> vkvk
>
>
> _________________________________________________________________
> Send and receive Hotmail on your mobile device: http://mobile.msn.com
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Reading All the values from ListBox on Submit

Posted by Rajesh Kalluri <rk...@manduca.com>.
Vijay,

I am assuming you are trying to do this with struts, you can also do this
the non-struts way in a similar fashion.

1)Here is a snippet of a jsp with a  select box with multiple="true".

<html:select property="selected" multiple="true" size="8">
	<html:options collection="cajas" property="articleId"
labelProperty="title"/>
</html:select>

2) Here is the submit button which will select all values in your select box
submits the form (it is the equivalent of user selecting all values.

	<html:submit property="validate"  onclick="selectAll(selected);return
true;"/>

3)The java script function used by the onclick button.

<script language="JavaScript">
function selectAll( )
{
for( j=0; j<selectAll.arguments.length; j++ )
  {
  col1 = selectAll.arguments[j];
  for(i=0; i<col1.options.length; i++ )
    {
	col1.options[ i ].selected = true;
	}
  } // end loop
  return true;
}
</script>

4)In your action you can retreive your form bean which has a properties
string[] with the users selection....

HTH
Rajesh

-----Original Message-----
From: Vijay Kumar [mailto:vijay_vkvk@hotmail.com]
Sent: Friday, August 02, 2002 10:09 AM
To: struts-user@jakarta.apache.org
Subject: Reading All the values from ListBox on Submit


Hi,
   Is there any to read all the values from Listbox on submit without
selecting them. What i am looking for is on submit all the values should be
read from ListBox and somehow pass it java. I can read all values on client
side using javascript but is there any way to pass them to java.
Any example or code on it.
Thanks in Advance.

Cheers
vkvk


_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>