Mui-js obtain the value of the check box, by using the array

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
        <title></title>
        <script src="js/mui.min.js"></script>
        <link href="css/mui.min.css" rel="stylesheet" />
        <script type="text/javascript" charset="utf-8">
            mui.init();
        </script>

    </head>

    <body>
        <header class="mui-bar mui-bar-nav">
            <!--顶部导航栏-带返回键-->
            <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
            <h1 class="mui-title">测试属性checkbox</h1>
        </header>
        <div class= "MUI-Content" > 
            < div class = "MUI-INPUT-Row-CheckBox MUI MUI-left" > <-! MUI-box on the left represents the left -> 
                < label > king </ label > 
                < the INPUT name = "CheckBox1" value = "king" of the type = "the CheckBox"   class = "RDS" > <-! the checked = "the checked" is selected by default; class = "rds" easy access dom node -> 
            </ div > 
            < div class = "MUI-INPUT-Row-CheckBox MUI MUI-left"> <-! MUI-checkbox Radio -> 
                <label > moving bricks </ label > 
                < INPUT name = "CheckBox1" value = "bricks transfer" type = "CheckBox" class = "RDS" > <-! Note radio button must be the same name, the representation is a group options -> 
            </ div > 
            < Button type = "Button" the onclick = "getVals ();" > Get value </ Button > 
        </ div > 
        < Script type = "text / JavaScript" >
            function getVals(){
                var res = GetRadioRes ( ' RDS ' );
                 IF (res.length <  . 1 ) { 
                    mui.toast ( ' select ' );
                     return ; 
                } 
                mui.toast (RES); 
            } 
            function getRadioRes (className) {
                 var rdsObj = document.getElementsByClassName (className); / * get the value * / 
                / * Alert (rdsObj.length); find a few test node * / 
                var checkVal =  new new Array();
                var k = 0;
                for(i = 0; i< rdsObj.length; i++){
                    if(rdsObj[i].checked){
                        checkVal[k] = rdsObj[i].value;
                        k++;
                    }
                }
                return checkVal;
            }
        </script>
    </body>

</html>

Guess you like

Origin www.cnblogs.com/fdxjava/p/11072098.html