js 獲取復選框所有選中的值


<form>
<input type="checkbox" name="game" value=111>111
<input type="checkbox" name="game" value=222>222
<input type="checkbox" name="game" value=333>333
<input type="checkbox" name="game" value=444>444
<input type="checkbox" name="game" value=555>555
<input type="button" value="click" onclick="show()">
</form>

 

獲取

<script>
function show(){
items = document.getElementsByName("game");
data = [];
for(x in items){
if(items[x].checked)
data.push(items[x].value);
}
alert(data);

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM