JBOSS 点滴

丰丰的博客

javascript 如何判断网页中某个 checkbox 有没有被选中?

<script   LANGUAGE="javascript">  
  function   whoisselected(){  
      var   a   =   document.getElementsByName("abc");  
      for   (var   i=0;   i<a.length;   i++){  
          if   (a[i].checked)  
              alert(i+"选中");  
      }  
  }  
  </script>  
  <form   method="POST"   >  
  <input   type="checkbox"   name="abc"   value="1">1  
  <input   type="checkbox"   name="abc"   value="2">2  
  <input   type="checkbox"   name="abc"   value="3">3  
  <input   type="checkbox"   name="abc"   value="4">4  
  <input   type="button"   value="看看选中谁"   onclick=javascript:whoisselected();>  
  </form>  

posted on 2007-03-14 15:19 半导体 阅读(826) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: