Javascript 表格显示问题下的结果+;阵列?
我无法在问题下方的表格上显示结果。我想我是对的。我还需要创建一个数组来保存答案,它将随机选择一个,而不必按照答案。我不知道如何在同一页上显示结果(我已经看过了,但运气不好),有人能帮我吗Javascript 表格显示问题下的结果+;阵列?,javascript,html,Javascript,Html,我无法在问题下方的表格上显示结果。我想我是对的。我还需要创建一个数组来保存答案,它将随机选择一个,而不必按照答案。我不知道如何在同一页上显示结果(我已经看过了,但运气不好),有人能帮我吗 <!doctype html> <html> <?php include "menu.html" ?> <head> <meta charset="UTF-8"> <title>Form</title> <link hre
<!doctype html>
<html>
<?php
include "menu.html"
?>
<head>
<meta charset="UTF-8">
<title>Form</title>
<link href="styles.css" rel="stylesheet">
<script>
function checkForm(){
var chk = true;
var Name = document.getElementById("txt");
var methd= document.getElementById("method");
var rad1= document.getElementById("radM");
var sel= document.getElementById("selM");
var necro = document.getElementById("a");
var guard = document.getElementById("b");
var ele = document.getElementById("c");
var shatter = document.getElementById("imp");
var cor = 0;
Name.style.backgroundColor="#fff";
methd.setAttribute("style", "display:none");
rad1.setAttribute("style", "display:none");
sel.setAttribute("style", "display:none");
if (Name.value==''){
Name.style.backgroundColor = "red";
methd.setAttribute("style", "display:inline");
chk = false;
}
if ((necro.checked==false) && (guard.checked==false) && (ele.checked==false)){
rad1.setAttribute("style", "display:inline");
}
if (shatter.value==0){
selM.setAttribute("style", "display:inline");
}
if (chk==false){
document.getElementById("error").setAttribute("style", "display:inline");
} else {
if (Name.value=="no"){
document.getElementById(txt).innerHTML += 'No';}
if (Name.value=="yes"){
document.getElementById(txt).innerHTML += 'Yes';}
if (ele.checked == true){
document.getElementById(c).innerHTML += 'Elementalist';}
if (necro.checked == true){
document.getElementById(a) += 'Necromancer';}
if (guard.checked == true){
document.getElementById(b) +='Guardian';}
if (shatter.value==1){
document.getElementById(imp) += 'Shatter';
}
if (shatter.value==2){
document.getElementById(imp) += 'Sunless';
}
if (shatter.value==3){
document.getElementById(imp) += 'Claw';
}
style.display = "inline";
innerHTML = "<span>You chose " + imp + txt + " correct!</span>";
}
}
</script>
</head>
<body>
<div class="page">
<article>
<div id="error" class="error"></div>
<h1>What Guild Wars 2 Profession Are You</h1>
<div class="cssTable" style="margin-top:-25px;">
<form method="post" action="thankyou.php" >
<table>
<tr><td colspan="3"></td></tr>
<tr>
<td><div align="right">In Guild Wars 2 Do You Like To Do Damage? </div> </td><td width="217"><input id="txt" name="txt" type="text" size="25"> <br/></td><td><div id="method" style="display:none"><img height="25px" src="purple.png" ></div></td><br/></tr>
<tr>
<td><div align="right">What Best Describes You?</div></td><td>
<input id="a" type="radio" name = "group1" value="A">Healer</input><br/>
<input id="b" type="radio" name = "group1" value="B">One With The Elements</input><br/>
<input id="c" type="radio" name = "group1" value="C">Darkness</input>
</td><td><div id="radM" style="display:none"><img height="25px" src="purple.png"></div></td>
</tr>
<tr>
<td>What One Skill Would You Like To Have?</td>
<td>
<select id="imp"><option value="0" selected="true">Pick A Skill</option>
<option value="1">Stealth</option>
<option value="2">Summon Illusions</option>
<option value="3">Great With A Bow and Arrow</option></select>
</td><td><div id="selM" style="display:none"><img height="25px" src="purple.png"></div></td>
</tr>
<tr><td colspan="3" align="right"><input type="button" class="styled-button-7" value="Send" onclick="checkForm()" /><span id="grde" style="padding-left:25px"> </span></td></tr></table></form></div></article>
</main></div>
</body>
</html>
形式
函数检查表(){
var chk=真;
var Name=document.getElementById(“txt”);
var methd=document.getElementById(“方法”);
var rad1=document.getElementById(“radM”);
var sel=document.getElementById(“selM”);
var necro=document.getElementById(“a”);
var guard=document.getElementById(“b”);
var ele=document.getElementById(“c”);
var shatter=document.getElementById(“imp”);
var-cor=0;
Name.style.backgroundColor=“#fff”;
method.setAttribute(“样式”,“显示:无”);
rad1.setAttribute(“样式”,“显示:无”);
sel.setAttribute(“样式”,“显示:无”);
如果(Name.value=''){
Name.style.backgroundColor=“红色”;
method.setAttribute(“样式”,“显示:内联”);
chk=假;
}
如果((坏死检查==假)&&(保护检查==假)&&(元素检查==假)){
rad1.setAttribute(“样式”,“显示:内联”);
}
if(shatter.value==0){
selM.setAttribute(“样式”,“显示:内联”);
}
如果(chk==false){
document.getElementById(“错误”).setAttribute(“样式”,“显示:内联”);
}否则{
如果(Name.value==“否”){
document.getElementById(txt).innerHTML+='No';}
如果(Name.value==“是”){
document.getElementById(txt).innerHTML+='Yes';}
if(ele.checked==true){
document.getElementById(c).innerHTML+='ElementList';}
如果(necro.checked==真){
document.getElementById(a)+=“亡灵巫师”;}
如果(guard.checked==true){
document.getElementById(b)+='Guardian';}
如果(破碎值==1){
document.getElementById(imp)+='Shatter';
}
如果(破碎值==2){
document.getElementById(imp)+='Sunless';
}
如果(破碎值==3){
document.getElementById(imp)+='Claw';
}
style.display=“inline”;
innerHTML=“您选择了”+imp+txt+“正确!”;
}
}
你是什么行业的激战2
在激战2中你喜欢造成伤害吗
什么最能描述你?
治疗者
一个包含元素
黑暗
你想要什么样的技能?
挑一项技能
隐身
召唤幻觉
弓箭棒极了
我将您对checkForm()
的调用从按钮上的onclick
移动到表单的onsubmit
,并开始从checkForm()
返回chk
。您应该完成checkForm()
函数,并开始让它一个字段一个字段地工作。有些属性是您试图错误访问的
您可以在以下网址查看:
您真的打算发布到thankyou.php吗?还是您的意图是严格的客户端发布?是的。。。不是为了这个问题,它是一个单独的一页,它将在所有的事情完成后。我所有的东西都转到那一页。所以是的,它应该在那里。我会在最后做那件事