473,372 Members | 999 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

Help needed in retrieving the selected values in the next page.:)

283 100+
Hello friends,
After thinking about this for sometime, i decided to post this in the java forum.
Well my problem here in detail is, i have 3 jsp pages where in a.jsp(for example) i have a combo box, based on the selection of the value in that combo box, b.jsp page gets populated with the value associated to a.jsp, and again based on the selection of value of the 2nd combobox my 3rd combo box gets populated, which is in c.jsp. I'm able to retrieve the values of all the 3 combo box, but im stuck at a point.
This is what i have done.....
a.jsp
[HTML]
<select name="branch" size="1" onChange="messageValue()">
<option value="">(Select Branch)<option>
<option value="Bombay" <%= branch.equals("Bombay") ? "selected" : "" %>>Bombay</option>
<option value="Delhi" <%= branch.equals("Delhi") ? "selected" : "" %>>Delhi</option>
and so on...
</select>
[/HTML]
the corresponding javascript is...
Expand|Select|Wrap|Line Numbers
  1.     function messageValue(){
  2. var messageIndex = document.expenqryForm.branch.selectedIndex;
  3. var selectedValue = document.expenqryForm.branch.options[messageIndex].value;
  4. document.expenqryForm.branch.value = selectedValue;
  5. document.expenqryForm.submit();
  6. }
  7.  
b.jsp page
[HTML]
<select name="branch" size="1" onChange="messageValue()">
<option value=""><option>
<option value="Bombay" <%= branch.equals("Bombay") ? "selected" : "" %>>Bombay</option>
<option value="Delhi" <%= branch.equals("Delhi") ? "selected" : "" %>>Delhi</option>
[/HTML]

and

Expand|Select|Wrap|Line Numbers
  1. <option value="">(select all)</option>
  2.      <%String publiCode=(String)request.getParameter("publiCode");
  3.     String publiHead=(String)request.getParameter("publiHead");
  4.     %>
  5.     <%publicity.ExpenForm eqobj=null;
  6.       ArrayList list=(ArrayList)request.getAttribute("pubHead");
  7.       for(Iterator itr=list.iterator();itr.hasNext();){
  8.       eqobj=(ExpenForm)itr.next();{    
  9.           %>
  10.  
  11.         <option value="<%=eqobj.getPubliCode() %>"><%=eqobj.getPubliHead() %></option>
  12.         <%}} %>
  13.     </select>
  14. <%session.setAttribute("list",list); %>
  15.  
the associated js function....
Expand|Select|Wrap|Line Numbers
  1. function messValue()
  2.     {
  3.       var messIndex = document.expen2Form.publiCode.selectedIndex;
  4.       var selValue = document.expen2Form.publiCode.options[messIndex].value;
  5.       document.expen2Form.publiCode.value=selValue;
  6.       document.expen2Form.publiHead.value=selValue;
  7.       document.expen2Form.submit();
  8.     }
  9.  

c.jsp page...
[HTML]//here i want to show the selected value of the previous page along with //other values
<option value="">(select all)</option>
<%
String publiCode = request.getParameter("publiCode");
publicity.ExpenForm eqobj1=null;
java.util.ArrayList list=(java.util.ArrayList)session.getAttribute("li st");
for(Iterator it=list.iterator();it.hasNext();){
eqobj1=(ExpenForm)it.next();{ %>
<option selected value="<%=eqobj1.getPubliCode() %>" <%=publicity_Code.equals(publiCode) ? "selected" : "" %> ><%=eqobj1.getPubliHead() %></option>
<%}} %>
</select>

[/HTML]


What i want to achieve here is, i want to send(show) the values which i select from the b.jsp page(which is comming from arraylist) to the next i.e c.jsp page with the selected value first and then the rest of the values.
At this point how im doing it is setting the arraylist in session and then populating it in the next page.....but in the c.jsp im getting the last value as selected even though i select some other value(i know why:))....i'm not sure this may be more of a js question....but since it involves jsp im putting it here.
Please help me coz im stuck here for some time now.:)..I hope ive conveyed myself clearly.:)

regards,
ajos
Feb 2 '08 #1
9 9895
r035198x
13,262 8TB
The selected value is easy to get.
Expand|Select|Wrap|Line Numbers
  1. request.getParameter("selectName");
To get all the values that were in the select, you can include a hidden combobox (multiple) that you populate with all the values. On submit of the form, call a javascript function which selects all the values in that hidden select an submit it. You then get all its values in the next page using
Expand|Select|Wrap|Line Numbers
  1. request.getParameterValues("hiddenComboboxName");
Feb 2 '08 #2
ajos
283 100+
The selected value is easy to get.
Expand|Select|Wrap|Line Numbers
  1. request.getParameter("selectName");
To get all the values that were in the select, you can include a hidden combobox (multiple) that you populate with all the values. On submit of the form, call a javascript function which selects all the values in that hidden select an submit it. You then get all its values in the next page using
Expand|Select|Wrap|Line Numbers
  1. request.getParameterValues("hiddenComboboxName");
Hi r0 thanks for the reply,
In my a.jsp the option values are hard coded, hence i just used js to get the value in the next page. But in my b.jsp page the value is getting populated by an arraylist.
Expand|Select|Wrap|Line Numbers
  1. <select name="publicity_Code" size="1" onChange="messageValue()">
  2.  
  3.     <option value="">(select all)</option>
  4.      <%String publiCode=(String)request.getParameter("publiCode");
  5.     String publiHead=(String)request.getParameter("publiHead");
  6.     %>
  7.  
  8.     <%publicity.ExpenForm eqobj=null;
  9.       ArrayList list=(ArrayList)request.getAttribute("pubHead");
  10.       for(Iterator itr=list.iterator();itr.hasNext();){
  11.       eqobj=(ExpenForm)itr.next();{    
  12.           %>
  13.  
  14.         <option value="<%=eqobj.getPubliCode() %>"><%=eqobj.getPubliHead() %></option>
  15.         <%}} %>
  16.  
  17.     </select>
  18.  
As you can see the value of the options im getting is different and the value to be displayed is different. Im confused on how to populate the values in the c.jsp page in a drop down showing the selected value.

Edit:did i mention combo box in my post....Im sorry its dropdown:)
Feb 2 '08 #3
r035198x
13,262 8TB
Hi r0 thanks for the reply,
In my a.jsp the option values are hard coded, hence i just used js to get the value in the next page. But in my b.jsp page the value is getting populated by an arraylist.
Expand|Select|Wrap|Line Numbers
  1. <select name="publicity_Code" size="1" onChange="messageValue()">
  2.  
  3.     <option value="">(select all)</option>
  4.      <%String publiCode=(String)request.getParameter("publiCode");
  5.     String publiHead=(String)request.getParameter("publiHead");
  6.     %>
  7.  
  8.     <%publicity.ExpenForm eqobj=null;
  9.       ArrayList list=(ArrayList)request.getAttribute("pubHead");
  10.       for(Iterator itr=list.iterator();itr.hasNext();){
  11.       eqobj=(ExpenForm)itr.next();{    
  12.           %>
  13.  
  14.         <option value="<%=eqobj.getPubliCode() %>"><%=eqobj.getPubliHead() %></option>
  15.         <%}} %>
  16.  
  17.     </select>
  18.  
As you can see the value of the options im getting is different and the value to be displayed is different. Im confused on how to populate the values in the c.jsp page in a drop down showing the selected value.

Edit:did i mention combo box in my post....Im sorry its dropdown:)
It doesn't matter if the values are coming from an arraylist. You can still add them to a hidden dropdown using JSP code.
Feb 2 '08 #4
ajos
283 100+
It doesn't matter if the values are coming from an arraylist. You can still add them to a hidden dropdown using JSP code.
Ok i did something like this...
in b.jsp page
[HTML]
<input type=hidden name="publiCode" value=<%=eqobj.getPubliCode() %>>
<input type=hidden name="publiHead" value=<%=eqobj.getPubliHead() %>>
<input type=hidden name="publicity_Code" value=<%=publicity_Code %>>
[/HTML]

and in c.jsp page
[HTML]
<select name="publicity_Code" size="1">

<option value="">(select all)</option>

<option value="<%=pubCode %>"><%=pubHead %></option>

</select>
[/HTML]
But only the last value from the list is getting populated in the c.jsp page
Feb 2 '08 #5
ajos
283 100+
At present the way i'm retrieving the values in c.jsp is by setting the arraylist from b.jsp in session and then retrieving the value in c.jsp....but when i select a particular value from b.jsp,....in c.jsp page the last value is shown as selected event though internally the result is showing correctly for the original selected value...Please help me in this situation.
Feb 2 '08 #6
r035198x
13,262 8TB
I thought you said you have the values in an arraylist.
So basically you'd have
Expand|Select|Wrap|Line Numbers
  1. ArrayList<String> list = getValues();
  2. <select name ="data" style="display:none" multiple>
  3. <%
  4.           for(String value : list) {
  5. %>
  6.      <option value ="<%=value%>"> <%=value%> 
  7. <%
  8.          }
  9. %>
This select would be on the form that you want to submit to c.jsp but would not be displayed to the user.
On submit of this form call a Javascript function called, say, selectAll which selects all the values in the select above.

In c.jsp you can get all the values of this select using
Expand|Select|Wrap|Line Numbers
  1. request.getParameterValues("data");
Disclaimer: Been a while since I wrote any web related code so you might have to check it a bit.
Feb 2 '08 #7
ajos
283 100+
I thought you said you have the values in an arraylist.
So basically you'd have
Expand|Select|Wrap|Line Numbers
  1. ArrayList<String> list = getValues();
  2. <select name ="data" style="display:none" multiple>
  3. <%
  4.           for(String value : list) {
  5. %>
  6.      <option value ="<%=value%>"> <%=value%> 
  7. <%
  8.          }
  9. %>
This select would be on the form that you want to submit to c.jsp but would not be displayed to the user.
On submit of this form call a Javascript function called, say, selectAll which selects all the values in the select above.

In c.jsp you can get all the values of this select using
Expand|Select|Wrap|Line Numbers
  1. request.getParameterValues("data");
Disclaimer: Been a while since I wrote any web related code so you might have to check it a bit.
Ok now i know this should be easy......im doing the same thing here, but slightly different from your code snippet...
Expand|Select|Wrap|Line Numbers
  1. <select name="publicity_Code" size="1" onChange="messageValue()">
  2.     <option value="">(select all)</option>
  3.     <%publicity.ExpenForm eqobj=null;
  4.       ArrayList list=(ArrayList)request.getAttribute("pubHead");
  5.       for(Iterator itr=list.iterator();itr.hasNext();){
  6.       eqobj=(ExpenForm)itr.next();{    
  7.           %>
  8.     <option value="<%=eqobj.getPubliCode() %>"><%=eqobj.getPubliHead() %></option>
  9.         <%}} %>
  10.     </select>
  11.  
If you notice here, in the <option> i have value attribute <%=eqobj.getPubliCode() %> and also the value to display as <%=eqobj.getPubliHead() %> from the bean. My question here is how do i store the values of the publiCode and publiHead values in js and populate in c.jsp completely with the value as selected. Im getting confused here ive done this before in a.jsp to b.jsp but the values were hard coded and in b.jsp i checked the condition as--
Expand|Select|Wrap|Line Numbers
  1. <option value="Bombay" <%= branch.equals("Bombay") ? "selected" : "" %>>Bombay</option>
.
Im not sure on how to do it in this case.
Feb 2 '08 #8
ajos
283 100+
Do i need to do set the ArrayList values in the b.jsp page and retrieve it in the c.jsp page, or can it be done by some other way?
Feb 2 '08 #9
ajos
283 100+
Do i need to do set the ArrayList values in the b.jsp page and retrieve it in the c.jsp page, or can it be done by some other way?
How do i retrieve the values of the dropdown from b.jsp page to c.jsp page without sending the arraylist to c.jsp page?...i guess this is the last part of my mission, so to speak:). Ive been able to write the javascript assciated with it...can somebody help me in retrieving the value in c.jsp page?
Feb 2 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Rob | last post by:
Hi everyone, I have a form that has several disabled text fields. In these text fields, I have initial values. Next to each text field lies a "copy" button. When clicked, the content of the...
4
by: krzysiek | last post by:
hello, i have several radiolists and checkboxlist that are generated dinamicly based on datasource. So frankly speaking i don't know names and number of that web controls cose they are always...
7
by: Aaron | last post by:
Complete code follows. I am new to .NET programming (and programming in general) and I am having a difficult time understanding how to fill a variable in one sub, and then access it from...
1
by: rich2912 | last post by:
I have a page, with three drop down boxes. Each has four choices linked to a database. Here is what I would like to do: I would like the results of the three choices, to be displayed on the...
2
by: walrama | last post by:
Hello, I have to write a small script which allows users to select individual tracks from a music album. Each track has a checkbox next to its title (to allow for multiple selections). Each...
4
by: jeet | last post by:
Plz help me.Problem is that On the first page I display all other user with checkbox and give user option to select only two user which he wants to send message. Tell me please how I'll get those...
2
by: ravisuguna | last post by:
Hi, I have a php page which has some checkboxes ,textfields and values.If I select a checkbox ,a particular value will be displayed in a textfield.I have a "go"button in the same page.I want the...
0
by: sconnoll | last post by:
import bsddb bsddb.btopen(file, flag='c', mode=438, btflags=0, cachesize=None, maxkeypage=None, minkeypage=None, pgsize=None, lorder=None) Can anyone help me with the values to use for...
13
by: deepunarayan | last post by:
Hi I have Problem in ASP. I have created a Multi choice Question page in ASP with Submit button. When I submit my page the User Selected values will be taken to the other page where validation...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.