String.prototype.InStr = function(str){
   if(str==null){
     str = "";
   }
   return this.indexOf(str);
}function SetChecked(){
  var _parent="1356";
  var _pre ="check";
  for(i=1;i<7;i++){
    if(_parent.InStr(i)>0)
      document.getElementById(_pre+i).checked=true;
 }
}

解决方案 »

  1.   

    <body>    
    <input type="checkbox" id="check1" />check1<br />
    <input type="checkbox" id="check2" />check2<br />
    <input type="checkbox" id="check3" />check3<br />
    <input type="checkbox" id="check4" />check4<br />
    <input type="checkbox" id="check5" />check5<br />
    <input type="checkbox" id="check6" />check6<br />
    </body>
    var value = "1356";
    var values = value.split("");
    for(var i=0;i<values.length;i++){
    var obj = document.getElementById("check"+values[i]);
    if(obj!=null){
    obj.checked = true;
    }
    }