A common example of a checkbox can be consulted:
About CheckBox Auto-check
CheckBox selected and passed through Ajax array to background receive
MP Combat Series (13) batch modification operation (front background asynchronous interaction)
This is said, or about the smart door lock unlock way. Usually, the mode of unlocking must choose two, or at least two, or you will not be able to eject the corresponding lock mode list for check, so. This requires the JS level of judgment, not all push to the server, so the user less good, more users, not much to say.
Or that sentence, the front-end can be done, do not back end, especially JS judgment. The front-end is primarily responsible for getting the interface, getting the data, rendering the HTML.
In the example, referring to the Layui front-end frame, for the Layui front-end frame, refer to my blog post: application examples of the Layui pop-up layer
The JS code is as follows:
function Test () {var names = Document.getelementsbyname ("lock_id"); var flag = false;//tag determines if a for (Var i=0;i) is selected<names. length;i++) {if (names[i].checked) {layui.use (' layer ', function () {var LA Yer= Layui.layer; Layer.open ({type:1, area: [' 400px ', ' 400px '], Content: ' <div align= "Center"> <labelclass= "Layui-form-label">Initial unlock</label><Div>Human Face recognition:<inputtype= "checkbox"name= "First_way"title= "Face Recognition"ID= "A1"onclick= "this.value= (this.value==0)? 1:0"> Password:<inputtype= "checkbox"name= "First_way"title= "Password"ID= "B2"onclick= "this.value= (this.value==0)? 1:0"> Two-dimensional code:<inputtype= "checkbox"name= "First_way"title= "QR Code"ID= "A3"onclick= "this.value= (this.value==0)? 1:0"> Remote:<inputtype= "checkbox"name= "First_way"title= "Remote"ID= "A4"onclick= "this.value= (this.value==0)? 1:0"> Fingerprint:<inputtype= "checkbox"name= "First_way"title= "fingerprint"ID= "A5"onclick= "this.value= (this.value==0)? 1:0"><BR/> <labelclass= "Layui-form-label">Follow-up lock</label><Div>Human Face recognition:<inputtype= "checkbox"name= "Laster_way"title= "Face Recognition"ID= "B1"onclick= "this.value= (this.value==0)? 1:0"> Password:<inputtype= "checkbox"name= "Laster_way"ID= "B2"title= "Password"onclick= "this.value= (this.value==0)? 1:0"> Two-dimensional code:<inputtype= "checkbox"name= "Laster_way"title= "QR Code"ID= "B3"onclick= "this.value= (this.value==0)? 1:0"> Remote:<inputtype= "checkbox"name= "Laster_way"title= "Remote"ID= "B4"onclick= "this.value= (this.value==0)? 1:0"> Fingerprint:<inputtype= "checkbox"name= "Laster_way"title= "fingerprint"ID= "B5"onclick= "this.value= (this.value==0)? 1:0"><BR/><P><inputtype= "button"value= "Submit"onclick= "test2 ()"/></P></Div>'//Here the content is an ordinary string}); }); Flag = true; break; }} if (!flag) {layui.use (' layer ', function () {var layer = Layui.layer; Layer.alert ("Select at least one latch", {icon:5}); }); return false; } }
JS's checkbox to determine common examples