JS Get checkbox check box get selected options
Share the next JavaScript get checkbox check box to get the option selected.
There are countless instances of the JavaScript get checkbox check box.
JS implementation:
var form = document.getElementById ("Form2"); var field = form.elements["test2"];var option = dining.getselectedoption ( form, field); var message = ""; for (var i = 0, len = option.length; i < Len; i++) {Message + = "SELECT ID:" + option[i].id + "\nselected Name:" + option[i].name + "\nselected value:" + option[i].value + "\ n";} alert (message);/* Gets the selected option */getselectedoption:function (Selectform, Selectionfield) {var result = [];var option = null; for (var i = 0; i < selectionfield.length; i++) {option = Selectionfield[i];if (option.checked) {result.push (option);} Www.jbxue.com}return result;} <form id= ' Form2 ' ><label> sort: </label><input id= ' aaaaa ' type= ' checkbox ' name= ' test2 ' value= ' 1 ' ><label for= ' aaaaa ' > Month sales </label><input id= ' bbbbb ' type= ' checkbox ' name= ' test2 ' value= ' 2 ' >< Label for= ' bbbbb ' > Score </label><input id= ' CCCCC ' type= ' checkbox ' name= ' test2 ' value= ' 3 ' ><label for= ' CCCCC ' > Offers </label> <br style= ' Clear:both ' ><laBel> Category: </label><input id= ' ddddd ' type= ' checkbox ' name= ' test2 ' value= ' 4 ' ><label for= ' ddddd ' > Business Package </label><input id= ' eeeee ' type= ' checkbox ' name= ' Test2 "value= ' 5 ' ><label for= ' eeeee ' > Cold dish </ Label><input id= ' fffff ' type= ' checkbox ' name= ' test2 ' ' value= ' 6 ' ></form> ',
JS get checkbox check box to get selected options