Home  >  Article  >  Web Front-end  >  Native JS implements form checkbook to obtain the selected value_javascript skills

Native JS implements form checkbook to obtain the selected value_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:28:101166browse

Get the selected data value from a form checkbox:

Copy code The code is as follows:

aa
bb
cc
dd




Use native JS writing method:
Copy code The code is as follows:

function checkedValues(){
var arr=new Array();
var checkbox=document.getElementByName('cb');
for(var i=0;iif(checkbox[i].checked==true ){
arr.push(checkbox[i].value);
alert(checkbox[i].value);
}
}
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn