复选框取值.html

来源:互联网 发布:淘宝网修改快递单号 编辑:程序博客网 时间:2024/05/16 06:36
<html>   <head>   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">    <title>My JSP 'hello.jsp' starting page</title>   </head>   <script type="text/javascript"> //页面取到选中的值 function check_black() {         var blackName = document.getElementsByName("black");         for(var i = 0; i < blackName.length; i++)     {        if(blackName[i].checked == true)        {           var a = blackName[i].value;   alert(a);       }     } }   </script>     <body>   <form action="" method="post" name = "form"> <input type="checkbox" name = "black" value = "1">打篮球 <input type="checkbox" name = "black" value = "2">看电视 <input type="checkbox" name = "black" value = "3">游泳 <input type="checkbox" name = "black" value = "4">爬山 <input type="checkbox" name = "black" value = "5">唱歌 <input type = "submit" name = "tijiao" value = "提交" onclick="check_black();"> </form>   </body> </html> 


原创粉丝点击