473,612 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
+ 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="messa geValue()">
<option value="">(Selec t 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="messa geValue()">
<option value=""><optio n>
<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="">(selec t all)</option>
<%
String publiCode = request.getPara meter("publiCod e");
publicity.Expen Form eqobj1=null;
java.util.Array List list=(java.util .ArrayList)sess ion.getAttribut e("list");
for(Iterator it=list.iterato r();it.hasNext( );){
eqobj1=(ExpenFo rm)it.next();{ %>
<option selected value="<%=eqobj 1.getPubliCode( ) %>" <%=publicity_Co de.equals(publi Code) ? "selected" : "" %> ><%=eqobj1.getP ubliHead() %></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 9910
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=<%=public ity_Code %>>
[/HTML]

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

<option value="">(selec t all)</option>

<option value="<%=pubCo de %>"><%=pubHea d %></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.getPub liCode() %> and also the value to display as <%=eqobj.getPub liHead() %> 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
1340
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 disabled text field is appended to the content of another textfield, the only one that isn't disabled (therefore the user can copy content from the other text fields, and also add what they want). I also have a remove button, which clears the content...
4
6544
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 different. How can i retreive selected values from those controls ?
7
2186
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 another. I have tried declaring them as shared, public, friend, etc and I always get an error stating that something is not valid on a local variable declaration. For example, in the following code for Sub DataGrid_Select, I have CurrentID and...
1
1262
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 next page, after the submit button is clicked. I have searched here, but am unfamiliar with the terminolgy for this kind of feature. Any help, or example code would be great.
2
1231
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 title also mentions the duration of the track. I have to pass the values of the selected tracks to the next page and this second page should display the total duration of all selected tracks (as well as the individual titles and durations). As I am...
4
3306
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 checkboxes value and name on the next page and send message to only those two selected user. Thanx in advance
2
2004
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 selected values and textfields to be displayed in the next page if i click the button.Pl guide me how to do this. I am sending the sample code below. arical.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
0
821
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 btflags? I'd like to tell the database manager that I want to allow duplicate values. The ORACLE Berkeley documentation addresses C (not Python), so I can't find the approprate btflags values documented for Python anywhere.
13
2140
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 will happen. My problem is, the number of question will be dynamic and I need to validate the scores and give the final scores. I tried to use a form collection via for each and validate with my answers but could nt successful
0
8162
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8105
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8605
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
6076
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5532
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4109
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2550
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 we have to send another system
1
1695
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1413
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.