Checkbox - 把文本转换为大写

  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function convertToUcase()
  5. {
  6. document.getElementById("fname").value=document.getElementById("fname").value.toUpperCase()
  7. document.getElementById("lname").value=document.getElementById("lname").value.toUpperCase()
  8. }
  9. </script>
  10. </head>
  11.  
  12. <body>
  13. <form name="form1">
  14. 名:<input type="text" id="fname" size="20" />
  15. <br /><br />
  16. 姓:<input type="text" id="lname" size="20" />
  17. <br /><br />
  18. 转换为大写
  19. <input type="checkBox" onclick="if (this.checked) {convertToUcase()}">
  20. </form>
  21. </body>
  22.  
  23. </html>