473,486 Members | 2,116 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

283 Contributor
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 9902
r035198x
13,262 MVP
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 Contributor
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 MVP
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 Contributor
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 Contributor
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 MVP
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 Contributor
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 Contributor
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 Contributor
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
1318
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
6529
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
2173
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
1256
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
1223
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
3299
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
1985
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
817
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
2121
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
7100
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6964
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7126
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7175
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6842
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5434
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4865
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
1378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
262
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.