日期:2014-05-16 浏览次数:20338 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html;charset=gb2312" /> <title>回答问题</title> </head> <body> <script type="text/javascript"> function judge(q) { switch(q) { case 1: { for(var ix = 0 ; ix < document.form.rd.length ; ++ ix) { if(document.form.rd[ix].checked) { if("2" == document.form.rd[ix].value) { document.getElementById("answer1").innerHTML = "你的答案是【" + document.form.rd[ix].value + "】" + "正确!"; alert("2"); } else { document.getElementById("answer1").innerHTML = "你的答案是【" + document.form.rd[ix].value + "】" + "错误~"; alert("3"); } } } break; } } } </script> <p>1 + 1 = ?</p> <form name="form"> <label><input type="radio" name="rd" value="1" />1</label> <label><input type="radio" name="rd" value="2" />2</label> <label><input type="radio" name="rd" value="3" />3</label>     <button onclick="judge(1)">确定</button> <br /> <div id="answer1"></div> </form> </body> </html>
<button onclick="judge(1)">确定</button>