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>