最近作了一个把只能单选的下拉列表转换成 复选框的例子,整理一下。
以前的
show.jsp
<input type="hidden" id="sIllId" name="sIllId" value="${sIllId}" />
<select name="illId" id="illId">
<option>-----</option>
</select>
sql=""and a.IllId.Id=? ""
被改后的
show.jsp
<input id="illnames" name="illnames" value="" onClick="selectbox();"/>
<input type="hidden" name="illId" id="illId" value="${param.illId}">
sql="and instr(?,a.IllId.Id)>0"
下面的js用来获取所选的值传回页面
selectbox=function(){
perinfo=window.showModalDialog("jsonquery.do?m=getJwIllNamesBox2&randid="+Math.random(),window,"dialogWidth:460px;dialogHeight:420px;center: yes;help:no;resizable:yes;status:yes;scroll=yes");
if(perinfo!=undefined){
infoarray=perinfo.split(";");
illnamesob=document.all("illnames");
illidsob=document.all("illId");
illnamesob.value="";
illidsob.value="";
for(i=0;i<infoarray.length;i++){
illarray=infoarray[i].split(",");
illnamesob.value+=illarray[1]+";";
illidsob.value+=illarray[0]+",";
}
illnamesob.value=illnamesob.value.substring(0,illnamesob.value.length-1);
illidsob.value=illidsob.value.substring(0,illidsob.value.length-1);
alert(illidsob.value);
}