Solved

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

Posted on 2004-03-25
11
173 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
A short article about problems I had with the new location API and permissions in Marshmallow
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

770 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