亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

原生JS實(shí)現(xiàn)表單checkbook獲取已選擇的值

 更新時(shí)間:2013年07月21日 18:01:37   作者:  
本文為大家介紹下采用原生JS實(shí)現(xiàn)從一個(gè)表單checkbox獲取到已選中的數(shù)據(jù)值,具體的實(shí)現(xiàn)如下,感興趣的朋友可以參考下哈,希望對(duì)大家有所幫助
從一個(gè)表單checkbox獲取到已選中的數(shù)據(jù)值:
復(fù)制代碼 代碼如下:

<input type="checkbox" name="cb" value="1" />aa
<input type="checkbox" name="cb" value="2" />bb
<input type="checkbox" name="cb" value="3" />cc
<input type="checkbox" name="cb" value="4" />dd
<br/>
<input type="button" value="提交" onclick="checkedValues()" />

采用原生JS寫法:
復(fù)制代碼 代碼如下:

function checkedValues(){
var arr=new Array();
var checkbox=document.getElementByName('cb');
for(var i=0;i<checkbox.length();i++){
if(checkbox[i].checked==true){
arr.push(checkbox[i].value);
alert(checkbox[i].value);
}
}
}

相關(guān)文章

最新評(píng)論