首页 > 其他 > 详细

单选按钮加confirm进行判断返回false任被选中问题

时间:2017-01-06 21:49:43      阅读:244      评论:0      收藏:0      [点我收藏+]
 1     <html>  
 2         <head>  
 3           
 4         <script language="javascript">  
 5             var checkValue = "";  
 6             var radios = document.getElementsByName("test");  
 7             function nowChecked(){  
 8                 for(var i=0;i<radios.length;i++){  
 9                     if(radios[i].checked){  
10                         checkValue = radios[i].value;  
11                     }  
12                 }  
13             }  
14             function change(n){  
15                   
16                 //alert("checkValue:"+checkValue+"  n:"+n);  
17                 if(checkValue != n){  
18                   
19                     if(confirm("确认修改?")){  
20                         radios[n].checked =true;  
21                         nowChecked();  
22                     }else{  
23                         radios[checkValue].checked = true;  
24                     }  
25                 }  
26             }  
27         </script>  
28         </head>  
29           
30         <body onload="nowChecked()">  
31             <input type="radio" name="test" value="0" checked="checked" onclick="change(0)"/>32             <input type="radio" name="test" value="1" onclick="change(1)"/>33         </body>  
34       
35     </html>  

 

单选按钮加confirm进行判断返回false任被选中问题

原文:http://www.cnblogs.com/licz/p/6257085.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!