从下一页的下拉列表中显示所选值。 [英] Displaying the selected value from the drop down in the next page.

查看:59
本文介绍了从下一页的下拉列表中显示所选值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我为我的应用程序进行了依赖性下拉过滤。我已经从数据库填充下拉并在html中检索。

[HTML]

< tr>

< td valign = QUOT;顶"宽度= QUOT; 138" height =" 26">< small>< font face =" Verdana">< strong> Branch< / strong>< / font>< / small>< / td>

< td width =" 379" height =" 26">

< select name =" branch"大小= QUOT 1 QUOT; onChange =" messValue()">

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

<%

publicity.Pub1Form pfObj = null;

ArrayList list =(ArrayList)request.getAttribute(" list");

for(Iterator itr = list.iterator(); itr.hasNext();){

pfObj =(Pub1Form)itr.next(); {


%> ;


< option value ="<%= pfObj.getDescription()%>"><%= pfObj.getDescription()%>< / option>

<%}}%>

< option value =""> ------------ -------------------------------------------< /选项> <无线电通信/>

< / select>

<%session.setAttribute(" list",list); %>

< / td>

< / tr>

[/ HTML]


这是我填充选择的arraylist。我生成的页面看起来像这样..

[HTML]

< select name =" branch"大小= QUOT 1 QUOT; onChange =" messValue()">

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


>
< option value =" Bombay"> Bombay< / option>


< option value =" Delhi"> Delhi< / option>


< option value =" Ahmedab​​ad"> Ahmedab​​ad< / option>


等等....

[/ HTML]


这是我的a.jsp(例如)。

javascript我写的是..

展开 | 选择 | Wrap | 行号

解决方案

hi,

您需要使用会话或cookie来携带从一页到另一页的价值。

在jsp中你可以更好地使用会话

在第一页设置下拉选择的值

展开 | 选择 | Wrap | 行号



hi,

你需要使用session或者cookie将值从一个页面传递到另一个页面。

在jsp中你可以更好地使用会话
第一页中的
设置下拉选择的值

展开 | 选择 | Wrap | 行号



感谢您的快速回复。这就是我正在做的事情。这部分不是问题。问题是,当我点击下拉框时,第二个下拉列表会被填充,但所选值始终是第一个值。我的问题是我需要做什么来修改b.jsp中选择的a.jsp中的选定值。我希望我在这里清楚吗?

b.jsp中的
生成的源是

[HTML]< select name =" branch" size =" 1">


< option value =" Bombay" true> Bombay< / option>


< option value =" Delhi" true> Delhi< / option>


< option value =" Ahmedab​​ad" true> Ahmedab​​ad< / option> [/ HTML]

如何显示所选值?


问候。



如果是PHP,我会做这样的事情。

[php]<?php


Hello all,
Im making a dependent drop down for my application for filtering purpose. I have populated the drop down from the database and retrieved in the html.
[HTML]
<tr>
<td valign="top" width="138" height="26"><small><font face="Verdana"><strong>Branch</strong></font></small></td>
<td width="379" height="26">
<select name="branch" size="1" onChange="messValue()">
<option value="">(select branch)</option>
<%
publicity.Pub1Form pfObj = null;
ArrayList list =(ArrayList)request.getAttribute("list");
for(Iterator itr = list.iterator(); itr.hasNext();){
pfObj=(Pub1Form)itr.next();{

%>

<option value="<%=pfObj.getDescription() %>"><%=pfObj.getDescription() %></option>
<%}} %>
<option value="">-------------------------------------------------------</option>

</select>
<%session.setAttribute("list",list); %>
</td>
</tr>
[/HTML]

This is the arraylist from where i populate the select. My generated page looks like this..
[HTML]
<select name="branch" size="1" onChange="messValue()">
<option value="">(select branch)</option>


<option value="Bombay">Bombay</option>


<option value="Delhi">Delhi</option>


<option value="Ahmedabad">Ahmedabad</option>

and so on....
[/HTML]

this is in my a.jsp(for example).
The javascript ive written is..

Expand|Select|Wrap|Line Numbers

解决方案

hi,
you need to use session or cookie to carry the value from one page to another page.
In jsp you can better use the session
in the first page set the value which was selected by the drop down

Expand|Select|Wrap|Line Numbers


hi,
you need to use session or cookie to carry the value from one page to another page.
In jsp you can better use the session
in the first page set the value which was selected by the drop down

Expand|Select|Wrap|Line Numbers


Thanks for the quick reply.Yup thats what im doing. This part is not the problem. The problem is when i click on the drop down box the 2nd drop down gets populated but the selected value is always the first value. My question is what js modification do i have to do to show the selected value from a.jsp as selected in b.jsp. I hope im clear here?

in b.jsp the source generated is
[HTML]<select name="branch" size="1">

<option value="Bombay" true>Bombay</option>

<option value="Delhi" true>Delhi</option>

<option value="Ahmedabad" true>Ahmedabad</option>[/HTML]
How would i show the selected value?

regards.

If it were PHP, I would have done something like this.
[php]<?php


这篇关于从下一页的下拉列表中显示所选值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆