ASP中判断动态单选按钮被选中的办法

 
  
  1. <script>  
  2.  
  3. function beforesubmit()  
  4. {  
  5. var checkflag = false;  
  6. var number = document.getElementsByName('ou_user');  
  7. for (var j=0;j<number.length;j++)  
  8. {  
  9. if(number[j].checked)  
  10. {  
  11. checkflag=true;  
  12. }  
  13. }  
  14. if (!checkflag)  
  15. {  
  16.   alert("至少選擇一位審核人!");  
  17.   //document.getElementByName("ou_user").focus();  
  18.   return false;  
  19.       
  20. }  
  21. var cond=confirm("確定申請嗎?")  
  22. if (!cond) {  
  23. return false;  
  24. }  
  25.  }  

 

 
  
  1. <form id="form1" name="form1" method="POST" action="<%=MM_editAction%>" onSubmit="return beforesubmit()"> 
  2.  
  3.               <%   
  4.             j=1 
  5.             if rs1.recordcount>0 then  
  6.              do while not rs1.eof  
  7.           %> 
  8.    
  9.          
  10.          <input name="ou_user" type="radio" id="ou_user<%=j%>" value="<%=rs1("u_id")%>"  /> 
  11.             <%=rs1("finishname")%> 
  12.       
  13.           <%  
  14.        jj=j+1  
  15.        rs1.movenext  
  16.        loop  
  17.        end if  
  18.      %> 
  19.  <input type="submit" name="button" id="button" value="確定"  /> 
  20. </form> 
  21.