修改后的JSP代码如下:
<%@ page language="java" contentType="text/html charset=UTF-8"pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html charset=UTF-8">
<link rel="stylesheet" type="text/css" href="CSS/css_style.css" />
<title>恒丰银行昆明分行外部评级机构管理系统</title>
</head>
<script>
var arr = new Array()
arr[0] = "昆明市,五华区,盘龙区,官渡区,西山区,东川区,呈贡县,晋宁县,富民县,宜良县,石林彝族自治县,嵩明县,禄劝彝族苗族自治县,寻甸回族彝族自治县,安宁市"
arr[1] = "曲靖市,麒麟区,马龙县,陆良县,师宗县,罗平县,富源县,会泽县,沾益县,宣威市"
arr[2] = "玉溪市,红塔区,江川县,澄江县,通海县,华宁县,易门县,峨山彝族自治县,新平彝族傣族自治县,元江哈尼族彝族傣族自治县"
arr[3] = "昭通市,昭阳区,鲁甸县,巧家县,盐津县,大关县,永善县,绥江县,镇雄县,彝良县,威信县,水富县"
arr[4] = "丽江市,隆阳区,施甸县,腾冲县,龙陵县,昌宁县"
arr[5] = "普洱市,古城区,玉龙纳西族自治县,永胜县,华坪县,宁蒗彝族自治县"
arr[6] = "临沧市,翠云区,普洱哈尼族彝族自治县,墨江哈尼族自治县,景东彝族自治县,景谷傣族彝族自治县,镇沅彝族哈尼族拉祜族自治县,江城哈尼族彝族自治县,孟连傣族拉祜族佤族自治县,澜沧拉祜族自治县,西盟佤族自治县"
arr[7] = "德宏市,临翔区,凤庆县,云县,永德县,镇康县,双江拉祜族佤族布朗族傣族自治县,耿马傣族佤族自治县,沧源佤族自治县"
arr[8] = "瑞丽市,潞西市,梁河县,盈江县,陇川县"
arr[9] = "泸水县,福贡县,贡山独龙族怒族自治县,兰坪白族普米族自治县"
arr[10] = "香格里拉县,德钦县,维西傈僳族自治县"
arr[11] = "大理市,漾濞彝族自治县,祥云县,宾川县,弥渡县,南涧彝族自治县,巍山彝族回族自治县,永平县,云龙县,洱源县,剑川县,鹤庆县"
arr[12] = "楚雄市,双柏县,牟定县,南华县,姚安县,大姚县,永仁县,元谋县,武定县,禄丰县"
arr[13] = "个旧市,开远市,蒙自县,屏边苗族自治县,建水县,石屏县,弥勒县,泸西县,元阳县,红河县,金平苗族瑶族傣族自治县,绿春县,河口瑶族自治县"
arr[14] = "文山县,砚山县,西畴县,麻栗坡县,马关县,丘北县,广南县,富宁县"
arr[15] = "景洪市,勐海县,勐腊县"
function init(index) {
var city = document.getElementById("city_" + index)
var cityArr = arr[0].split(",")
for (var i = 0 i < cityArr.length i++) {
city[i] = new Option(cityArr[i], cityArr[i])
}
}
function getCity(comp) {
//获得控件序号(1..*)
var index = comp.id.charAt(comp.id.length - 1)
var province = document.getElementById("province_" + index)
var city = document.getElementById("city_" + index)
var cityArr = arr[province.selectedIndex].split(",")
city.length = 0
//将城市数组中的值填充到城市下拉框中
for (var i = 0 i < cityArr.length i++) {
city[i] = new Option(cityArr[i], cityArr[i])
}
}
</script>
<script>
function displayResult(){
var table=document.getElementById("table-7")
var rows = table.rows.length
var currRow = rows - 1
var row = table.insertRow(currRow)
var cell1=row.insertCell(0)
var cell2=row.insertCell(1)
var index = currRow - 2
cell1.innerHTML="+抵押物"
cell2.innerHTML="抵押物证号:<input name='clot_no_" + index + "'><input type='button' value='+' onClick='displayResult()'><br/>"
+"抵押物归属地:"
+"<select id='province_" + index + "' size=1 onchange='getCity(this)'>"
+"<option value=0>昆明</option>"
+"<option value=1>曲靖</option>"
+"<option value=2>玉溪</option>"
+"<option value=3>昭通</option>"
+"<option value=4>保山</option>"
+"<option value=5>丽江</option>"
+"<option value=6>普洱</option>"
+"<option value=7>临沧</option>"
+"<option value=8>德宏</option>"
+"<option value=9>怒江</option>"
+"<option value=10>迪庆</option>"
+"<option value=11>大理</option>"
+"<option value=12>楚雄</option>"
+"<option value=13>红河</option>"
+"<option value=14>文山</option>"
+"<option value=15>版纳</option>"
+"</select>"
+"<select id='city_" + index + "' style='width: auto'></select><br/>"
+"抵押物地址:<input name='clotaddr" + index + "'>"
init(index)
}
</script>
<body onload="init(1)">
<div id="wrapper">
<header class="SiteHeader"> <img src="PIC/HF_LOGO.png"
alt="HFKM-KJB" style="width: 89px height: 34px"> </header>
<aside class="NavSidebar"> <nav>
<h2>当前用户</h2>
<ul>
<li>用户名:</li>
<li>角色:</li>
</ul>
</nav> <nav>
<h2>功能导航</h2>
<ul>
<%
String mana_type=session.getAttribute("mana_type").toString()
String menu=""
if (mana_type.equals("系统管理员")) {
menu="<li><a href=\"showOrg.do\">查看评估机构</a></li><li><a href=\"CreateOrg.jsp\">新增评估机构</a></li><li><a href=\"showPle_done.do\">查看已抽签抵押物</a></li><li><a href=\"showPle.do\">查看未抽签抵押物</a></li><li><a href=\"showPle.do\">抽签结果查看</a></li>"
} else
{
menu="<li><a href=\"showOrg.do\">查看评估机构</a></li><li><a href=\"showPle_done.do\">查看已抽签抵押物</a></li><li><a href=\"showPle.do\">查看未抽签抵押物</a></li><li><a href=\"CreatePle.jsp\">新增抵押物</a></li><li><a href=\"showPle.do\">抵押物抽签</a></li>"
}
%>
<%=menu%>
</ul>
</nav> <section>
<h2>系统设置</h2>
<ul>
<li><a href="">修改密码</a></li>
<li><a href="logout.do">退出登录</a></li>
</ul>
</section> <br />
<br />
<br />
<br />
</aside>
<main> <article class="Content"> <header
class="ArticleHeader"> </header>
<h3 align=center>新增业务信息</h3>
<br />
<form name="frmCrePle" action="CrePle.do">
<table border="1" id="table-7">
<tr>
<td>借款人名称</td>
<td><input name="loan_na"></td>
</tr>
<tr>
<td>借款人身份证号/统一社会信用代码</td>
<td><input name="loan_no"></td>
</tr>
<tr>
<td>抵押人名称</td>
<td><input name="plg_na"></td>
</tr>
<tr>
<td id="td_na_1">抵押物</td>
<td id="clot_no">
抵押物证号:<input name="clot_no_1"><input type="button" value="+" onClick="displayResult(this)"><br/>
抵押物归属地:
<select id="province_1" size=1 onchange="getCity(this)">
<option value=0>昆明</option>
<option value=1>曲靖</option>
<option value=2>玉溪</option>
<option value=3>昭通</option>
<option value=4>保山</option>
<option value=5>丽江</option>
<option value=6>普洱</option>
<option value=7>临沧</option>
<option value=8>德宏</option>
<option value=9>怒江</option>
<option value=10>迪庆</option>
<option value=11>大理</option>
<option value=12>楚雄</option>
<option value=13>红河</option>
<option value=14>文山</option>
<option value=15>版纳</option>
</select>
<select id="city_1" style="width: auto"></select><br/>
抵押物地址:<input name="clotaddr_1">
</td>
</tr>
<tr align="center">
<td colspan="2"><input type="submit" value="提交"></td>
</tr>
</table>
</form>
</article> </main>
<footer>
<p class="Disclaimer">
© 2017 恒丰银行昆明分行<br> Disign by KJB-TianSIR
</p>
</footer>
</div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>
<HEAD>
<TITLE>New Document </TITLE>
<script>
var city=[["北京","天津","上海","重庆"] ]
function getCity(){
var sltProvince=document.getElementById("province")
var sltCity=document.getElementById("city")
var provinceCity=city[sltProvince.selectedIndex-1]
sltCity.length=1
for(var i=0i<provinceCity.lengthi++){
sltCity[i+1]=new Option(provinceCity[i],provinceCity[i])
}
}
//这里就是取当前被选中的下拉框的值。
function showInfo(){
var sltProvince=document.getElementById("province")
var sltCity=document.getElementById("city")
for(var i=0i<sltCity.lengthi++){
if(sltCity.options[i].selected)
document.getElementById("cityValue").innerHTML=sltCity.options[i].value
}
for(var i=0i<sltProvince.lengthi++){
if(sltProvince.options[i].selected)
document.getElementById("pro").innerHTML=sltProvince.options[i].value
}
}
</script>
</head>
<BODY>
<form action="somepage.asp" name=theForm">
<select name="province" id="province" onchange="getCity()">
<option value="0" selected>请选择所在省份</option>
<option value="直辖市">直辖市</option>
</select>
<select id="city" name="city">
<option value="0">请选择所在城市</option>
</select>
<input type="button" onclick="showInfo()"/>
</form>
<div id="showvalue">
省份:<span id="pro"> </span> 城市 : <span id="cityValue"> </span>
</div>
</BODY>
</HTML>
自己写的。测试了。看看是不是你想要的结果。