HTML
<input type="checkbox" value="One" checked="checked" id="r1" name="g" /> <label for="r1"> One </label> <input type="checkbox" value="Two" id="r2" name="g" /> <label for="r2"> Two </label> <input type="button" value="Status" onclick="MyFunction()" /> Javascript
function MyFunction() { var chk = document.getElementsByName("g"); for (var i = 0; i < chk.length; i++) { if (chk[i].checked == true) { alert("Checkbox at index " + i + " is checked!"); alert("Text at index " + i + chk[i].nextSibling.innerHTML); } } } Here I am getting the Index of the checkboxes which are checked. How to get the text of the selected Checkboxes?
Demo:http://jsfiddle.net/u95uN/
Thanks for ur help.