我有一个页面,它是一个考试页面,它选择所有 MCQ 问题及其答案......并在服务器端页面加载中添加 div.innerHtml += “html tags” + question + 包含答案的单选按钮,它一直在选择从数据库直到所有问题都在客户端呈现,问题是我在表单中添加了所有这些问题和标签,最后有一个输入提交按钮,它应该提交所有单选按钮值但即使我设置表单操作我也无法获得单选按钮值...
这是一些代码:
using (SqlDataReader sr1 = command1.ExecuteReader())
{
cc.InnerHtml = "<form id=\"form2\" name=\"form2\" method=\"post\" action=\"\">";
while (sr1.Read())
{
i++;
iString = i.ToString();
questionText = sr1["text"].ToString();
question_first_wrong_answer = sr1["first_wrong_answer"].ToString();
question_second_wrong_answer = sr1["second_wrong_answer"].ToString();
question_right_answer = sr1["right_answer"].ToString();
questionValue = (int)sr1["value"];
c = answerPos.Next(0, 10);
cc.InnerHtml += "<span>" + iString + "- " + questionText +"</span>"
+ "<br />"
+ "<table style=\"width:77%; margin-left: 47px;\">"
+ "<tr>"
+ " <td style=\"width: 210px\">"
+ " <input type=\"radio\" name=\"question" + iString + "a\" value=\"" + question_first_wrong_answer + "\" />" + question_first_wrong_answer + "</td>"
+ "<td style=\"width: 210px\">"
+ "<input type=\"radio\" name=\"question" + iString + "a\" value=\"" + question_second_wrong_answer + "\" />" + question_second_wrong_answer + "</td>"
+ "<td style=\"width: 210px\">"
+ "<input type=\"radio\" name=\"question" + iString + "a\" value=\"" + question_right_answer + "\" />" + question_right_answer + "</td>"
+ "</tr>"
+ "</table>"
+ "<br />";
}
sr1.Close();
cc.InnerHtml += "<input id=\"Submit1\" type=\"submit\" value=\"Submit\" />"
+ "</form>";
}