MUI H5+常见控件的使用之单选按钮

单选



var genderMale = document.getElementById('Gender_male'); //男
var genderFemale = document.getElementById('Gender_female'); //女


Get

var data = {
Gender: getRadioValue('gender'),
function getRadioValue(className){
    var rdsObj = document.getElementsByClassName(className);
    var checkVal = null;
    for(i = 0; i < rdsObj.length; i++){
        if(rdsObj[i].checked){checkVal = rdsObj[i].value;}
    }
    if(checkVal=='on'){
    	return 1;
    }else{
    	return 0;
    }  
}




Set 

if(result.userInfo.Gender == 1) {
	genderMale.checked = true;
}
if(result.userInfo.Gender == 0) {
	genderFemale.checked = true;
}


你可能感兴趣的:(Web,H5)