JS's checkbox to determine common examples

Source: Internet
Author: User

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"> &nbsp;&nbsp;Password:<inputtype= "checkbox"name= "First_way"title= "Password"ID= "B2"onclick= "this.value= (this.value==0)? 1:0">&nbsp;&nbsp;Two-dimensional code:<inputtype= "checkbox"name= "First_way"title= "QR Code"ID= "A3"onclick= "this.value= (this.value==0)? 1:0">&nbsp;&nbsp;Remote:<inputtype= "checkbox"name= "First_way"title= "Remote"ID= "A4"onclick= "this.value= (this.value==0)? 1:0">&nbsp;&nbsp;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"> &nbsp;&nbsp;Password:<inputtype= "checkbox"name= "Laster_way"ID= "B2"title= "Password"onclick= "this.value= (this.value==0)? 1:0">&nbsp;&nbsp;Two-dimensional code:<inputtype= "checkbox"name= "Laster_way"title= "QR Code"ID= "B3"onclick= "this.value= (this.value==0)? 1:0">&nbsp;&nbsp;Remote:<inputtype= "checkbox"name= "Laster_way"title= "Remote"ID= "B4"onclick= "this.value= (this.value==0)? 1:0">&nbsp;&nbsp;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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.