每当我单击提交按钮时,它应该使用数据库中给出的所需值来验证答案。我该如何解决这个错误?
该按钮执行包含表和行的表单提交。我已经包含了一段代码。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<button type="submit" id="btn1" onclick="getanswer();"> submitanswer </button>
<tr>
<td>{{Result.id}} ) {{Result.questions}}</td>
</tr>
<tr>
<td><input type="radio" id="choice1" name="{{Result.id}}" class="ans" value="{{Result.choice1}}">{{Result.choice1}}</td>
</tr>
$(document).ready(function() {
$("#btn1").click(function() {
$(".btn1").show();
$(".btn1").attr("disabled", true);
});
});
function getanswer() {
document.getElementById("useranswer").innerHTML = "";
var e = document.getElementsByTagName('input');
for (i = 0; i <= e.length; i++) {
if (e[i].type == 'radio') {
if (e[i].checked) {
document.getElementById("useranswer").innerHTML += "Q" + e[i].name + "Answer you selected is :" + e[i].value + "<br/>";
}
}
}
}
梦里花落0921
相关分类