Home > Web Front-end > JS Tutorial > 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
Release: 2016-05-16 17:28:10
Original
1193 people have browsed it

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);
}
}
}
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template