JSP部分:

<div class="form-group">    
            <label class="col-md-3 control-label">能源类型:</label>  
                <div>  
                    <label class="checkbox-inline">  
                        <input type="checkbox" > 深层地热  
                        </label>  
                    <label class="checkbox-inline">  
                        <input type="checkbox" > 浅层地热  
                    </label>  
                    <label class="checkbox-inline">  
                        <input type="checkbox" > 污水  
                    </label>  
                    <label class="checkbox-inline">  
                        <input type="checkbox" > 燃气  
                    </label>  
                    <label class="checkbox-inline">  
                        <input type="checkbox"  > 其它  
                        <input style="display:none;" name="energyType" type="text" />  
                    </label>  
                </div>  
</div>  

JS部分:

var strs= new Array(); //定义一数组  
var str="${data.energyStationRet.energyType}";  
strs=str.split(","); //字符分割  
  
  
for (i=0;i<strs.length ;i++ )  
{     
    console.log(strs[i].trim());  
    if(strs[i].trim() == "深层地热") {  
        $("#Checkbox1").attr("checked","true");  
    }  
    else if(strs[i].trim() == "浅层地热") {  
        $("#Checkbox2").attr("checked","true");  
    }  
    else if(strs[i].trim() == "污水") {  
        $("#Checkbox3").attr("checked","true");  
    }  
    else if(strs[i].trim() == "燃气") {  
        $("#Checkbox4").attr("checked","true");  
    }  
    else if(strs[i].trim() == "") {  
    }  
    else {  
        $("#Checkbox6").attr("checked","true");  
        var Checkbox5 = document.getElementById('Checkbox5');  
        Checkbox5.style.display='inline-block';  
        Checkbox5.value = strs[i].trim();  
          
    }  
      
}   
/*弹出部分*/  
 function energyTypeCheck (chk) {  
    var Checkbox5 = document.getElementById('Checkbox5');  
    if (chk.checked) {  
        Checkbox5.style.display='inline-block';  
    }else {  
        Checkbox5.style.display='none';  
  
    }  
}  

 

相关文章:

  • 2021-08-20
  • 2022-03-03
  • 2021-10-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-07
  • 2021-11-08
  • 2022-12-23
  • 2022-12-23
  • 2021-08-31
  • 2021-12-23
  • 2022-12-23
相关资源
相似解决方案