初学javascript面向对象(一)

来源:互联网 发布:mac看b站卡 编辑:程序博客网 时间:2024/05/13 07:45


<body>
 理赔用户岗位<br>
 <div style="display:none" id="divRole">
 </div>
</body>
<script>
 function Role(name,value){
  this.name=name;
  this.value=value;
 }

 var roleArr=new Array(3);
 

 var audit=new Role("审核","R01");
 roleArr[0]=audit;

 var check=new Role("复核","R02");
 roleArr[1]=check;

 var sign=new Role("签批","Ro3");
 roleArr[2]=sign;


 function loadRole(){
  var html="<table>";
  for(var i=0;i<roleArr.length;i++){
   var role=roleArr[i];
   var name=role.name;
   var value=role.value;
   html+="<tr>";
   html+= "<td>";
   html+=  "<input type='checkbox' name='role' value='"+value+"'/>";
   html+= "</d>";
   html+= "<td>";
   html+=  name;
   html+= "</d>";
   html+="</tr>";
  }
  html+="</table>";

  document.getElementById("divRole").innerHTML=html;
  document.getElementById("divRole").style.display="block";
 }

 loadRole();
</script>