文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Javascript 如何得到input type="radio" 的值?

Javascript 如何得到input type="radio" 的值?

时间:2008-07-02  来源:wataxi

<script   language="JavaScript">   
  <!--   
  function   chk(){   
  var   obj   =   document.getElementsByName('imgposition');   
  for   (i=0;i<obj.length;i++){   
    if   (obj[i].checked){   
      alert(obj[i].value);   
      return;   
    }   
  }   
  alert('你没选');   
  }   
  //-->   
  </script>   
  <form   name=form1>   
  <input   type="radio"   name="imgposition"   value="1">   
  <input   type="radio"   name="imgposition"   value="2">   
  <input   type="radio"   name="imgposition"   value="3">   
  </form>   
  <input   type="button"   onclick="chk()">   

for example:


<INPUT type=radio name="radio" CHECKED>1-10 years old
<INPUT type=radio name="radio">11 years old
<INPUT type=radio name="radio">12-120 years old
This example uses script to detect which radio button the user selects.

<SCRIPT>
function detect()
 {
    if (radio[0].checked)
        alert("You're between 1 and 10 years old.")
    else if (radio[1].checked)
        alert("You're 11 years old.")
    else
        alert("You're between 12 and 120 years old.")
 }
</SCRIPT>
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载