如何用JAVAScript判断radio是否选中 [已结帖,结帖人:sunhongxiang]   .
[华 软 网]
编程论坛  楼主 在写JAVAScript的时候,如何判断单选按钮是否被选中,并且在什么时候调用,急啊!!!!     .
[华 软 网]
编程论坛 5 个网友回答:
HTML code
<script>  
  function  check()  
  {  
  for(i=0;i <document.form1.r1.length;i++)  
  if(document.form1.r1[i].checked)  
  {alert(document.form1.r1[i].value);return;}  
  }  
</script>  


  <form  name=form1>  
  <input  type=radio  name=r1  value=1>  
  <input  type=radio  name=r1  value=2>  
  <input  type=radio  name=r1  value=3>  
  <input  type=button  onclick=check()>  
  </form>
    .
[华 软 网]
编程论坛 7 个网友回答:
HTML code
<script>  
  function  check()  
  {  
  for(i=0;i <document.form1.r1.length;i++)  
  if(document.form1.r1[i].checked)  
  {alert(document.form1.r1[i].value);return;}  
  }  
</script>  


  <form  name=form1>  
  <input  type=radio  name=r1  value=1>  
  <input  type=radio  name=r1  value=2>  
  <input  type=radio  name=r1  value=3>  
  <input  type=button  onclick=check()>  
  </form>
    .
[华 软 网]
编程论坛 10 个网友回答:
引用 2 楼 rocketsuperman 的回复:

比如这样:

<script> 
  function  check() 
  { 
  for(i=0;i <document.form1.r1.length;i++) 
  if(document.form1.r1[i].checked) 
  {alert(document.form1.r1[i].value);return;} 
  } 
</script> 


  <form  name=form1> 
  <input  type=radio  name=r1  value=1> 
  <input  type=radio  name=r1  value=2> 
  <input  type=radio  name=r1  value=3> 
  <input  type=button  onclic…


引用 2 楼 rocketsuperman 的回复:

比如这样:

<script> 
  function  check() 
  { 
  for(i=0;i <document.form1.r1.length;i++) 
  if(document.form1.r1[i].checked) 
  {alert(document.form1.r1[i].value);return;} 
  } 
</script> 


  <form  name=form1> 
  <input  type=radio  name=r1  value=1> 
  <input  type=radio  name=r1  value=2> 
  <input  type=radio  name=r1  value=3> 
  <input  type=button  onclic…
 

相关文章: