JavaScript 取用 ASP.Net 2.0 的 RadioButtonList 與 CheckBoxList

  • 58732
  • 0
  • AJAX
  • 2008-03-23

JavaScript 取用 ASP.Net 2.0 的 RadioButtonList 與 CheckBoxList

  1. <script type="text/javascript" >
  2. function getRadioButtonList( ) {
  3. var radioObj = document.getElementById ( "<%=RadioButtonList1.ClientID %>" );
  4. var radioList = radioObj.getElementsByTagName ( 'input' );
  5. for ( var i = 0; i < radioList.length; i++)
  6. {
  7. if (radioList[i].checked )
  8. {
  9. alert (radioList[i].value );
  10. }
  11. }
  12. }
  13. function getCheckBoxList( ) {
  14. var cboxObj = document.getElementById ( "<%=CheckBoxList1.ClientID %>" );
  15. var cboxList = cboxObj.getElementsByTagName ( 'input' );
  16. var lbList = cboxObj.getElementsByTagName ( 'label' );
  17. for ( var i = 0; i < cboxList.length; i++)
  18. {
  19. if (cboxList[i].checked )
  20. {
  21. alert (lbList[i].innerText );
  22. }
  23. }
  24. }
  25. </script>