[英]Online-Quiz: Dividing the answers and questions in to 3 Categories by choosing different Radio-Buttons
I have a problem by updating my Online-Quiz. 我有更新在线测验的问题。
I want to Categorize my Questions and Answers by clicking on Radio Buttons. 我想通过单击单选按钮对我的问题和答案进行分类。 This is my HTML-Code: 这是我的HTML代码:
<fieldset id="my" data-role="controlgroup" data-mini="true">
<legend>Choose a Category</legend>
<input type="radio" name="radio-mini" id="radio-mini-1" value="choice-1" />
<label for="radio-mini-1">Amateur</label>
<input type="radio" name="radio-mini" id="radio-mini-2" value="choice-2" />
<label for="radio-mini-2">Middle</label>
<input type="radio" name="radio-mini" id="radio-mini-3" value="choice-3" />
<label for="radio-mini-3">Legend</label>
</fieldset>
<a href="#" id="Next" data-role="button" onclick="nextStart()">Send</a>
So I have 3 Radio Buttons. 所以我有3个单选按钮。 These radio buttons have also their own multidimensional arrays. 这些单选按钮也具有自己的多维数组。 After I choose one category, the array-name should be renamed to an generally array name "question", because for this array name I have lots of different function which I don`t want to write for every single array. 选择一个类别后,应将数组名称重命名为一般的数组名称“问题”,因为对于此数组名称,我有很多不同的功能,我不想为每个数组编写。 My Javascript-Code after I have clicked on the Send-Button: 我单击发送按钮后的Java代码:
function nextStart()
{
//document.getElementById("quiz").submit();
$.mobile.changePage( "quiz.html",
{
transition: "pop",
reverse: false,
changeHash: false
});
$("input[name=radio-mini]:checked").each(function next()
{
if ($(this).val() = "choice-1")
{
category = "amateur";
}
else if ($(this).val() = "choice-2")
{
schwierigkeit = "middle";
}
else
{
schwierigkeit = "legend";
}
});
}
Now I tell my general array "question" from which array it got the informations: 现在,我告诉我的一般数组“问题”,它从哪个数组中获取信息:
if(category = "amateur")
{
question = amateur.slice();
}
else if (category = "middle")
{
question = middle.slice();
}
else
{
question = legend.slice();
}
If I click the category 2 or 3 "legend" and then on the Send Button I get only on the next side, the answers and questions from the first array "amateur". 如果我单击类别2或3“传奇”,然后在“发送”按钮上,我只能从另一侧获得第一组“业余”中的答案和问题。 So I think it doesn't save the right array name after the function 所以我认为它不能在函数后保存正确的数组名称
nextStart()
But I don`t got the solution to fix it.. Can somebody help me? 但是我没有解决的办法。有人可以帮我吗?
It would be nice, thanks beforehand :-) 会很好的,事先感谢:-)
As Ben Lee already stated, you are using asignment operator instead of equality. 正如Ben Lee所说,您正在使用赋值运算符而不是相等符。 Should be like this: 应该是这样的:
if ($(this).val() == "choice-1") {
category = "amateur";
}
else if ($(this).val() == "choice-2") {
category = "middle";
}
else {
category = "legend";
}
I totally missed the following code, which contains the same error. 我完全错过了以下代码,其中包含相同的错误。 Thanks, Ben! 谢谢,本!
if(category == "amateur")
{
question = amateur.slice();
}
else if (category == "middle")
{
question = middle.slice();
}
else
{
question = legend.slice();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.