如题,JS里获取某项单选框选中的次数

解决方案 »

  1.   

    定义一个计数器,click一下,+1
      

  2.   

    哥们如果是一个单选框的选中次数的话就没意义了。
    如果是多个的话,可以遍历所有的radio来看是不是选中了,选中了就+1
      

  3.   

    你定义一个全局变量,每次onclick时,次数加1
      

  4.   

       int i=0
      <循环标签>
             <html标签....>
       i++
      </循环标签>
      

  5.   

    <html><head> </head>
      <script type="text/javascript">
       var i=1;
       function fun(){
           alert("单击了"+i+"次")
       i++;
       }
      </script>
      <body>
       <input type="button"  value="单击" id="aa" onclick="fun()" />
      </body>
    </html>
      

  6.   


    <html>
      <head>
        <base href="<%=basePath%>">
        
        <title>My JSP 'MyJsp.jsp' starting page</title>
        
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->  </head>
      <script type="text/javascript" src="js/jquery-1.3.2.js"></script>
      <script type="text/javascript">
       var i=1;
       function fun(){
           alert("单击了"+i+"次")
           $("#hid").attr("value",i);
           var hh=$("#hid").val();
           alert(hh);
           i++;
       }
      </script>
      <body>
       <input type="button"  value="单击" id="aa" onclick="fun()" />
       <input type="hidden" id="hid"  value="">
      </body>
    </html>