jsp的修改页面中怎么样获取到复选框和下拉列表里面的信息然后显示在修改页面
程序员文章站
2024-01-02 12:38:22
...
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript" src="js/jquery.js" ></script>
<title></title>
</head>
<body onload="setSelected();">
子品牌:
<select name="brand" id="brand" >
<option value="联邦家居" >联邦家居</option>
<option value="联邦米尼" >联邦米尼</option>
<option value="联邦梦斐思" >联邦梦斐思</option>
<option value="联邦宝达" >联邦宝达</option>
<option value="联邦高登" >联邦高登</option>
</select><br/><br/>
所在的销售公司:
<select name="company" id="company">
<option value="华南销售">华南销售</option>
<option value="中南销售">中南销售</option>
<option value="华东销售">华东销售</option>
<option value="上海销售">上海销售</option>
<option value="北部销售">北部销售</option>
<option value="西部销售">西部销售</option>
<option value="联邦米尼销售">联邦米尼销售</option>
<option value="联邦梦斐思销售">联邦梦斐思销售</option>
<option value="联邦宝达销售">联邦宝达销售</option>
<option value="联邦高登销售">联邦高登销售</option>
</select><br/><br/>
经营系列:
<div id="divv">
<input type="checkbox" name="product" id="product" value="艾" />艾
<input type="checkbox" name="product" id="product" value="定" />定
<input type="checkbox" name="product" id="product" value="柚" />柚
<input type="checkbox" name="product" id="product" value="东方"/>东方
<input type="checkbox" name="product" id="product" value="素"/>素
<input type="checkbox" name="product" id="product" value="新"/>新
<input type="checkbox" name="product" id="product" value="温"/>温
</div>
<script>
var arr=[];
<c:forEach items="${bean.list}" var="a">
//把获取的集合数据存到arr数组中
arr.push({id:"${a.id}",obj:{id:"${a.id}",productList:"${a.productList}",spaceHelp:"${a.isSpaceHelp}",space:"${a.isSpace}",placeCity:"${a.isPlaceCity}",blankCity:"${a.isBlankCity}",customer:"${a.isOldCustom}",company:"${a.company}",brand:"${a.brand}"}});
</c:forEach>
var str_1="${param.id}";
var that_obj={};
for(var i=0;i<arr.length;i++){
if(arr[i].id==str_1){
that_obj=arr[i].obj;
}
}
function setSelected(){
var oldType_mini = '联邦米尼';
var oldType_lbmn = '联邦米尼销售';//测试数据
var oldType_brand = that_obj.brand;//获取品牌
var types1 = document.getElementById("brand");
var types2 = document.getElementById("company");
for(var i = 0; i < types1.options.length;i++){
if(types1.options[i].value == oldType_mini){//把oldType_mini换成that_obj.brand
types1.options[i].selected = true;
}
}
//复选框
//var my_check = '东方,艾,温';//测试数据
var my_check = that_obj.productList;
var checks = document.getElementById("divv").childNodes;
console.log(checks.length);
for(var i = 0; i < checks.length;i++){
if(i%2!=0){
console.log(checks[i].value);
if(my_check.indexOf(checks[i].value)!=-1){
checks[i].checked = true;
}
}
}
}
</script>
</body>
</html>