<select name="OCCUPATION_CLASS" onChange="fnOccpClass();" disabled>
<option value="">--- Please Select ---</option>
<%
for (int i = 0; i < vCLASS_CODE.size(); i++)
{
String sCODE = (String) vCLASS_CODE.elementAt(i);
String sDESCP = (String) vCLASS_DESCP.elementAt(i);
%>
<option value="<%=sCODE%>" <% if (OCCUPATION_CLASS.equals(sCODE)){out.println("selected");} %>><%=sDESCP%></option><% } %>
</select>
我尝试显示值=&#34; sDESCP&#34;进入文本框..但失败了
<input type="text" value="<%=sDESCP%>" name="OCCUPATION_CLASS">
答案 0 :(得分:0)
将输入文本框修改为
<input id="inp" "type="text" value="<%=sDESCP%>" name="OCCUPATION_CLASS">
,下拉为
<select name="OCCUPATION_CLASS" id="dd" onChange="fnOccpClass();" disabled>
<option value="">--- Please Select ---</option>
<%
for (int i = 0; i < vCLASS_CODE.size(); i++)
{
String sCODE = (String) vCLASS_CODE.elementAt(i);
String sDESCP = (String) vCLASS_DESCP.elementAt(i);
%>
<option value="<%=sCODE%>" <% if (OCCUPATION_CLASS.equals(sCODE)){out.println("selected");} %>><%=sDESCP%></option><% } %>
</select>
现在在javascript代码部分的fn0ccpClass()函数中
function fnOccpClass() {
document.getElementById("inp").value=document.getElementById
('dd').options[document.getElementById('dd').selectedIndex].text;
}