欢迎来到DIVCSS5查找CSS资料与学习DIV CSS布局技术!
  <htmlxmlns="http://www.w3.org/1999/xhtml"> 
 
  <head> 
 
  <metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/> 
 
  <title>js动态设置div的值.html</title> 
 
  </head> 
 
  <body> 
 
  <formmethod="post"name="form1"> 
 
    <label><inputtype="radio"name="radio"value="1-10岁"οnclick="ok(this.value);">1-10岁</label> 
 
    <label><inputtype="radio"name="radio"value="11岁"οnclick="ok(this.value);">11岁</label> 
 
    <label><inputtype="radio"name="radio"value="12-120岁"οnclick="ok(this.value);">12-120岁</label> 
 
   </form> 
 
   <divid="test">11111</div> 
 
   <scriptlanguage="javascript"type="text/javascript"> 
 
  functionok() 
 
  { 
 
   vartemp=document.getElementsByName("radio"); 
 
   for(i=0;i<temp.length;i++){ 
 
   //遍历Radio 
 
    if(temp[i].checked) 
 
     { 
 
     //alert("你选择了"+temp[i].value); 
 
     //获取Radio的值 
 
     document.getElementById('test').innerHTML=temp[i].value;//必须如此格式写,用jquery的获取值的方式不能达到效果,ly2013-02-07   
 
     } 
 
    } 
 
  } 
 
  </script>
 
  </body> 
 
  </html>
 
  

如需转载,请注明文章出处和来源网址:http://www.divcss5.com/shili/s54634.shtml