1,前台代碼:
//<input id="zonestr" runat="server" type="text" style="display:none" />
//該控制項的作用是存放擷取到的多項input的值,用於與後台代碼的互動
<div class="multisele_content" id="div1" onclick="javascript:GetZone()">
<input id="zonestr" runat="server" type="text" style="display:none" />
<div class="multisele_content_box">
<div class="se_box">
<input id="zonexiyao" runat="server" type="checkbox" class="se_chk" checked="true" name="zone" value="西藥"/>
<p>西藥</p>
</div>
<div class="se_box">
<input id="zonezhongyao" runat="server" type="checkbox" class="se_chk" name="zone" value="中藥"/>
<p> 中藥</p>
</div>
<div class="se_box">
<input id="zoneshengwu" runat="server" type="checkbox" class="se_chk" name="zone" value="生物藥"/>
<p>生物藥</p>
</div>
<div class="se_box">
<input id="zonehuaxueyuanliao" runat="server" type="checkbox" class="se_chk" name="zone" value="化學原料藥"/>
<p>化學原料藥</p>
</div>
<div class="se_box">
<input id="zoneyaobao_fuliao" runat="server" type="checkbox" class="se_chk" name="zone" value="藥包材,輔料"/>
<p>藥包材,輔料</p>
</div>
<div class="se_box" style="width:200px;">
<input id="zonehuagong_zhongjian" runat="server" type="checkbox" class="se_chk" name="zone" value="化工產品及中間體"/>
<p>化工產品及中間體</p>
</div>
</div>
<div class="multisele_content_box">
<div class="se_box">
<input id="zonezhongyao_yinping" runat="server" type="checkbox" class="se_chk" name="zone" value="中藥材及飲片"/>
<p>中藥材及飲片</p>
</div>
<div class="se_box">
<input id="zonezhiwutiqu" runat="server" type="checkbox" class="se_chk" name="zone" value="植物提取物"/>
<p>植物提取物</p>
</div>
<div class="se_box" style="width:140px;">
<input id="zonebiaozhun_zhenduan" runat="server" type="checkbox" class="se_chk" name="zone" value="標準品,診斷試劑"/>
<p>標準品,診斷試劑</p>
</div>
<div class="se_box">
<input id="zoneyiliaoqixie" runat="server" type="checkbox" class="se_chk" name="zone" value="醫學器械"/>
<p>醫學器械</p>
</div>
<div class="se_box">
<input id="zoneyiqishebei" runat="server" type="checkbox" class="se_chk" name="zone" value="儀器裝置"/>
<p>儀器裝置</p>
</div>
<div class="se_box">
<input id="zonebaojianshipin" runat="server" type="checkbox" class="se_chk" name="zone" value="保健食品"/>
<p>保健食品</p>
</div>
<div class="se_box" style="width:60px;">
<input id="zoneother" runat="server" type="checkbox" class="se_chk" name="zone" value="其他"/>
<p>其他</p>
</div>
</div>
</div>
2,js代碼:
//擷取經營範圍
function GetZone()
{
//擷取input所在div的對象
var ob = document.getElementById("div1");
//擷取div中所用的IUPUT控制項集合
var col = div1.getElementsByTagName("INPUT");
var str="";
var count=0;
//迴圈遍曆,判斷INPUT是否選中
for(var i=0 ;i<col.length;i++)
{
if(col[i].checked==true)
{
count++;
if(count==1)
{
str+=col[i].value;
}
else
{
str+="/"+col[i].value;
}
//str+=col[i].value+"/";
}
}
document.getElementById("zonestr").value=str;
//alert(document.getElementById("zonestr").value);
}