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
- function messageValue(){
- var messageIndex = document.expenqryForm.branch.selectedIndex;
- var selectedValue = document.expenqryForm.branch.options[messageIndex].value;
- document.expenqryForm.branch.value = selectedValue;
- document.expenqryForm.submit();
- }
[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
- <option value="">(select all)</option>
- <%String publiCode=(String)request.getParameter("publiCode");
- String publiHead=(String)request.getParameter("publiHead");
- %>
- <%publicity.ExpenForm eqobj=null;
- ArrayList list=(ArrayList)request.getAttribute("pubHead");
- for(Iterator itr=list.iterator();itr.hasNext();){
- eqobj=(ExpenForm)itr.next();{
- %>
- <option value="<%=eqobj.getPubliCode() %>"><%=eqobj.getPubliHead() %></option>
- <%}} %>
- </select>
- <%session.setAttribute("list",list); %>
Expand|Select|Wrap|Line Numbers
- function messValue()
- {
- var messIndex = document.expen2Form.publiCode.selectedIndex;
- var selValue = document.expen2Form.publiCode.options[messIndex].value;
- document.expen2Form.publiCode.value=selValue;
- document.expen2Form.publiHead.value=selValue;
- document.expen2Form.submit();
- }
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