我正在为探路者活动创建角色扮演游戏问卷。我想创建一个它来根据角色回答列出的问题的方式为他们提供各种奖励。我打算调整下面的内容,我只需要知道如何编写代码来显示为每个问题选择的输入单选按钮值。
这是代码:
<!DOCTYPE html>
<html>
<script>
function myFunction()
{
var queone = document.getElementById("qone").value;
var quetwo = document.getElementById("qtwo").value;
var quethr = document.getElementById("qthr").value;
if (queone == 1) {
alert("You are now +2 Acrobatics");
}
else if (queone == 2) {
alert("You are now +2 to Bluff");
}
else if (queone == 3) {
alert("You are now +2 Diplomacy");
}
if (quetwo == 1) {
alert("You are now +2 Acrobatics");
}
else if (quetwo == 2) {
alert("You are now +2 to Bluff");
}
else if (quetwo == 3) {
alert("You are now +2 Diplomacy");
}
if (quethr == 1) {
alert("You are now +2 Acrobatics");
}
else if (quethr == 2) {
alert("You are now +2 to Bluff");
}
else if (quethr == 3) {
alert("You are now +2 Diplomacy");
}
}
</script>
<div>
<h2 align="center">Fantasy Survey</h2>
<p>Do you love fantasy games?</p></br></br>
<input id="qone" name="radio1" value="1" checked="" type="radio">Yes</br></br>
<input id="qone" name="radio1" value="2" type="radio">Meh</br></br>
<input id="qone" name="radio1" value="3" type="radio">No</br></br>
<p>Have you ever considered playing pen and paper games?</p></br></br>
<input id="qtwo" name="radio2" value="1" checked="" type="radio"> Yes</br></br>
<input id="qtwo" name="radio2" value="2" type="radio"> Meh</br></br>
<input id="qtwo" name="radio2" value="3" type="radio"> No</br></br>
<p>Do you like Pathfinder?</p></br></br>
<input id="qthr" name="radio3" value="1" checked="" type="radio"> Yes</br></br>
<input id="qthr" name="radio3" value="2" type="radio"> Meh</br></br>
<input id="qthr" name="radio3" value="3" type="radio"> No</br></br>
<input type="button" onclick="myFunction()" value="Submit" />
</div>
</html>
我希望根据他们通过单选按钮值所做的选择来显示带有奖励的警报。我觉得我很接近,但我不知道如何只提醒与所选特定单选按钮相关的值。如果您有更好的方法,我很高兴听到它,但我希望它与我在上面发布的内容类似。
谢谢你的时间!!