Home > Web Front-end > JS Tutorial > Use js to get the value of checkbox

Use js to get the value of checkbox

小云云
Release: 2018-03-10 15:13:39
Original
2585 people have browsed it

This article mainly shares with you how to use js to obtain the value of the checkbox. I hope it can help you.

<input type="checkbox" name="test" value="值1" />显示的内容
<input type="checkbox" name="test" value="值2" />显示的内容
<input type="checkbox" name="test" value="值3" />显示的内容
<input type="checkbox" name="test" value="值n" />显示的内容
....
<input type="button" value="提交" onclick="send()" />

JS:

function send(){
    var id = document.getElementsByName(&#39;test&#39;);
    var value = new Array();
    for(var i = 0; i < id.length; i++){
     if(id[i].checked)
     value.push(id[i].value);
    } 
  window.location =&#39;某Action!netWorkingUpdate?concentratorids=&#39;+value.toString();
Copy after login

Backend:

String value = request.getParameter("concentratorids");
Copy after login

Then intercept this value

Related recommendations:

##js gets select Detailed explanation of the method of tag value value

jQuery implementation method of obtaining the value value of the selected option

PHP Accumulation of value values ​​of the same key in multi-dimensional arrays function

The above is the detailed content of Use js to get the value of checkbox. For more information, please follow other related articles on the PHP Chinese website!

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