Solved

Passing selected values from list to another window which is a jsp

Posted on 2004-03-25
11
174 Views
Last Modified: 2010-04-17
hi , my requirement is
i got one select option list with multiple values in one jsp . I have to select more than one values from the list and pass those values to the pop up window and populate them in a table in order to display those selected values in pop up window which  is an another jsp.
please send me code how can i do this using jsp and javascript.

Sai.
0
Comment
Question by:MaheshJ
  • 6
  • 3
11 Comments
 
LVL 30

Expert Comment

by:Mayank S
ID: 10675652
if you want to select multiple values, then it would not be an 'option' list.
0
 

Author Comment

by:MaheshJ
ID: 10685782
what i mean to say is there is a list box which contains multiple items in that. Iam required to select multiple items from that list using ctrl button. now i need to pass these all selected values to next jsp , where in i populate these values and fill in table dynamically.

Sai
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10685895
Sure you can:

<SELECT MULTIPLE SIZE=5>
 <OPTION VALUE="o1">Option 1
 <OPTION VALUE="o2">Option 2
 <OPTION VALUE="o3">Option 3
 <OPTION VALUE="o4">Option 4
 <OPTION VALUE="o5">Option 5
 <OPTION VALUE="o6">Option 6
</SELECT>

0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 30

Expert Comment

by:Mayank S
ID: 10685897
Bad code. I forgot a </OPTION> tag everywhere.
0
 

Author Comment

by:MaheshJ
ID: 10702369
what u have suggested to not suited for the requirement. With the above code we can select multiple values , ok , but what i need to do is all the selected values from above option list must be passed to next JSP. So how can we pass all the selected values from option list to next JSP ?
 
Sai
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10702399
Set it as parameters or an attribute of the request object, or the session. Something like:

String sValues[] ....
// -> the array contains all the selected values from the list

request.setAttribute ( "SelectedValues", sValues ) ;

In the other JSP, use:

String[] sValues = ( String [] ) request.getAttribute ( "SelectedValues" ) ;

- and display the contents of the String array.
0
 

Author Comment

by:MaheshJ
ID: 10731279
ok u said that to set it as parameter or attribute. now in current jsp to get the selected values in the list i have to go for javascript and how can i fill sValues[] and set it as parameter or attribute ?
I am getting selected values using javascript and im not able to get those selected values using java in jsp.
thanks for ur help please suggest me how can i get the selected list in jsp with out using javascript so that i can set as parameter.

sai
0
 
LVL 30

Accepted Solution

by:
Mayank S earned 50 total points
ID: 10731371
If you have the values in a list, then you should just forward the request (it will automatically have the parameters of the form which was submitted). You can use request.getParameter ( "list_name" ) ; to get the selected value.
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 10983555
Please proceed with that recommendation.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is an explanation of a simple data model to help parse a JSON feed
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question