标签:document 风景 back element 选择 class break lock 测试
<html> <head> <style type="text/css"> ul{ list-style:none; margin:0px; } .close{ display:none; } .open{ display:block; } </style> </head> <script type="text/javascript"> function showResult(){ var number=0; var sum=0; while(number!=5){ var flag=false; var oradioNodes = document.getElementsByName("name"+(number++)); for(var x =0;x<oradioNodes.length;x++){ if(oradioNodes[x].checked){ sum=parseInt(oradioNodes[x].value)+sum; flag=true; break; } } if(!flag){ document.getElementById("result").className="open"; } }
if(sum>0){ alert(sum+"分"); } if(sum>=5 && sum<=15){ document.getElementById("result_1").className="open"; document.getElementById("result_2").className="close"; document.getElementById("result").className="close"; }else if(sum>=16){ document.getElementById("result_2").className="open"; document.getElementById("result_1").className="close"; document.getElementById("result").className="close"; } } </script> <body> <div><h1>命运预言大师</h1></div> <div id="t_1"> <h3>第一题</h3> <span>您喜欢的颜色是?</span> <ul> <li><input type="radio" value="1" name="name0" />红色</li> <li><input type="radio" value="2" name="name0" />黄色</li> <li><input type="radio" value="3" name="name0" />蓝色</li> <li><input type="radio" value="4" name="name0" />黑色</li> <li><input type="radio" value="5" name="name0" />白色</li> </ul> </div> <div id="t_2"> <h3>第二题</h3> <span>您喜欢的运动是?</span> <ul> <li><input type="radio" value="1" name="name1" />篮球</li> <li><input type="radio" value="2" name="name1" />足球</li> <li><input type="radio" value="3" name="name1"/>乒乓球</li> <li><input type="radio" value="4" name="name1" />羽毛球</li> <li><input type="radio" value="5" name="name1" />长跑</li> </ul> </div> <div id="t_2"> <h3>第三题</h3> <span>您喜欢的风景是?</span> <ul> <li><input type="radio" value="1" name="name2" />大海</li> <li><input type="radio" value="2" name="name2" />山水</li> <li><input type="radio" value="3" name="name2"/>荒漠</li> <li><input type="radio" value="4" name="name2" />草原</li> <li><input type="radio" value="5" name="name2" />其他</li> </ul> </div> <div id="t_2"> <h3>第四题</h3> <span>您喜欢的数字是?</span> <ul> <li><input type="radio" value="1" name="name3" />1-3</li> <li><input type="radio" value="2" name="name3" />4-6</li> <li><input type="radio" value="3" name="name3"/>7-9</li> <li><input type="radio" value="4" name="name3" />10</li> <li><input type="radio" value="5" name="name3" />其他</li> </ul> </div> <div id="t_2"> <h3>第五题</h3> <span>您喜欢的动物是?</span> <ul> <li><input type="radio" value="1" name="name4" />狗</li> <li><input type="radio" value="2" name="name4" />猫</li> <li><input type="radio" value="3" name="name4"/>老鼠</li> <li><input type="radio" value="4" name="name4" />老虎</li> <li><input type="radio" value="5" name="name4" />其他</li> </ul> </div> <div> <input type="button" value="查看测试结果" onclick="showResult()"/> <div id="result" class="close">请先选择答案!</div> <div id="result_1" class="close">矮戳穷</div> <div id="result_2" class="close">高富帅</div> </div> </body> </html>
标签:document 风景 back element 选择 class break lock 测试
原文地址:http://www.cnblogs.com/wangyinxu/p/7144079.html