我想提出一个HTML表单,并在用户提交表单的页面aspx
将加载显示表单的结果。我有20个问题总与各5个单选按钮。出于某种原因,当我尝试检索选定的单选按钮直通for循环,它只显示一个答案。我究竟做错了什么?
我曾尝试在改变值循环,但它只是似乎无法正确显示。
下面是该aspx.cs代码
public void DisplayResults(double[] results)
{
try
{
int q = 1;
for (int i = 0; i <= 19; i++)
{
if (i == 0)
{
txtResults.Text = "Course Results";
if (results[i] == 1)
{
txtResults.Text += "Q" + q + ": Strongly Disagree";
}
else if (results[i] == 2)
{
txtResults.Text += "Q" + q + ": Disagree";
}
else if (results[i] == 3)
{
txtResults.Text += "Q" + q + ": Neutral";
}
else if (results[i] == 4)
{
txtResults.Text += "Q" + q + ": Agree";
}
else if (results[i] == 5)
{
txtResults.Text += "Q" + q + ": Strongly Agree ZERO";
}
}
else if (i == 11)
{
txtResults.Text = "Professor Results";
if (results[i] == 1)
{
txtResults.Text += "Q" + q + ": Strongly Disagree";
}
else if (results[i] == 2)
{
txtResults.Text += "Q" + q + ": Disagree";
}
else if (results[i] == 3)
{
txtResults.Text += "Q" + q + ": Neutral";
}
else if (results[i] == 4)
{
txtResults.Text += "Q" + q + ": Agree";
}
else if (results[i] == 5)
{
txtResults.Text += "Q" + q + ": Strongly Agree ELEVEN";
}
}
else
{
if (results[i] == 1)
{
txtResults.Text += "Q" + q + ": Strongly Disagree";
}
else if (results[i] == 2)
{
txtResults.Text += "Q" + q + ": Disagree";
}
else if (results[i] == 3)
{
txtResults.Text += "Q" + q + ": Neutral";
}
else if (results[i] == 4)
{
txtResults.Text += "Q" + q + ": Agree";
}
else if (results[i] == 5)
{
txtResults.Text += "Q" + q + ": Strongly Agree ELSE";
}
}
if (txtResults.Text == "")
{
throw new Exception();
}
}
}
catch (Exception e)
{
Console.Write(e.Message, "Error");
}
}
下面是ASPX代码
<fieldset>
<legend>Feedback Results</legend>
<asp:TextBox ID="txtResults" runat="server" TextMode="MultiLine" Width="100%" Height="500px"></asp:TextBox>
</fieldset>
这里是我的html代码
<h3>Please answer these questions to the best of your knowledge:</h3>
<fieldset>
<legend>Course Content (Organization, Clarity of Expectations/Directions, Balance/Appropriateness)</legend>
1. The course (or section) presented skills in a helpful sequence
<br />
<input type="radio" name="q1" value="5" />strongly agree
<input type="radio" name="q1" value="4" />agree
<input type="radio" name="q1" value="3" />neutral
<input type="radio" name="q1" value="2" />disagree
<input type="radio" name="q1" value="1" />strongly disagree
<br />
<br />
2. The course (or section) provided an appropriate balance between instruction and practice
<br />
<input type="radio" name="q2" value="5" />strongly agree
<input type="radio" name="q2" value="4" />agree
<input type="radio" name="q2" value="3" />neutral
<input type="radio" name="q2" value="2" />disagree
<input type="radio" name="q2" value="1" />strongly disagree
<br />
<br />
3. The course (or section) was appropriate for the stated level of the class
<br />
<input type="radio" name="q3" value="5" />strongly agree
<input type="radio" name="q3" value="4" />agree
<input type="radio" name="q3" value="3" />neutral
<input type="radio" name="q3" value="2" />disagree
<input type="radio" name="q3" value="1" />strongly disagree
<br />
<br />
4. The course (or section) was organized in a way that helped me learn
<br />
<input type="radio" name="q4" value="5" />strongly agree
<input type="radio" name="q4" value="4" />agree
<input type="radio" name="q4" value="3" />neutral
<input type="radio" name="q4" value="2" />disagree
<input type="radio" name="q4" value="1" />strongly disagree
<br />
<br />
5. The lab helped to complement the lectures
<br />
<input type="radio" name="q5" value="5" />strongly agree
<input type="radio" name="q5" value="4" />agree
<input type="radio" name="q5" value="3" />neutral
<input type="radio" name="q5" value="2" />disagree
<input type="radio" name="q5" value="1" />strongly disagree
<br />
<br />
6. The course (or section) provided a mixture of explanation and practice
<br />
<input type="radio" name="q6" value="5" />strongly agree
<input type="radio" name="q6" value="4" />agree
<input type="radio" name="q6" value="3" />neutral
<input type="radio" name="q6" value="2" />disagree
<input type="radio" name="q6" value="1" />strongly disagree
<br />
<br />
7. The course (or section) was effectively organized
<br />
<input type="radio" name="q7" value="5" />strongly agree
<input type="radio" name="q7" value="4" />agree
<input type="radio" name="q7" value="3" />neutral
<input type="radio" name="q7" value="2" />disagree
<input type="radio" name="q7" value="1" />strongly disagree
<br />
<br />
8. The course (or section) assignments and lectures usefully complemented each other
<br />
<input type="radio" name="q8" value="5" />strongly agree
<input type="radio" name="q8" value="4" />agree
<input type="radio" name="q8" value="3" />neutral
<input type="radio" name="q8" value="2" />disagree
<input type="radio" name="q8" value="1" />strongly disagree
<br />
<br />
9. The course (or section) instructions (including, manuals, handouts, etc.) were clear
<br />
<input type="radio" name="q9" value="5" />strongly agree
<input type="radio" name="q9" value="4" />agree
<input type="radio" name="q9" value="3" />neutral
<input type="radio" name="q9" value="2" />disagree
<input type="radio" name="q9" value="1" />strongly disagree
<br />
<br />
10. The course (or section) work helped me understand concepts more clearly
<br />
<input type="radio" name="q10" value="5" />strongly agree
<input type="radio" name="q10" value="4" />agree
<input type="radio" name="q10" value="3" />neutral
<input type="radio" name="q10" value="2" />disagree
<input type="radio" name="q10" value="1" />strongly disagree
<br />
<br />
11. Instructions for course (or section) materials (including manuals, handouts, etc.) were clear
<br />
<input type="radio" name="q11" value="5" />strongly agree
<input type="radio" name="q11" value="4" />agree
<input type="radio" name="q11" value="3" />neutral
<input type="radio" name="q11" value="2" />disagree
<input type="radio" name="q11" value="1" />strongly disagree
<br />
<br />
12. The lab complemented my understanding of the lectures
<br />
<input type="radio" name="q12" value="5" />strongly agree
<input type="radio" name="q12" value="4" />agree
<input type="radio" name="q12" value="3" />neutral
<input type="radio" name="q12" value="2" />disagree
<input type="radio" name="q12" value="1" />strongly disagree
</fieldset>
<br />
<br />
<fieldset>
<legend> Instructor Specific Questions</legend>
1. The instructor clearly presented the skills to be learned
<br />
<input type="radio" name="q13" value="5" />strongly agree
<input type="radio" name="q13" value="4" />agree
<input type="radio" name="q13" value="3" />neutral
<input type="radio" name="q13" value="2" />disagree
<input type="radio" name="q13" value="1" />strongly disagree
<br />
<br />
2. The instructor effectively presented concepts and techniques
<br />
<input type="radio" name="q14" value="5" />strongly agree
<input type="radio" name="q14" value="4" />agree
<input type="radio" name="q14" value="3" />neutral
<input type="radio" name="q14" value="2" />disagree
<input type="radio" name="q14" value="1" />strongly disagree
<br />
<br />
3. The instructor presented content in an organized manner
<br />
<input type="radio" name="q15" value="5" />strongly agree
<input type="radio" name="q15" value="4" />agree
<input type="radio" name="q15" value="3" />neutral
<input type="radio" name="q15" value="2" />disagree
<input type="radio" name="q15" value="1" />strongly disagree
<br />
<br />
4. The instructor effectively presented the tools (e.g. materials, skills, and techniques) needed
<br />
<input type="radio" name="q16" value="5" />strongly agree
<input type="radio" name="q16" value="4" />agree
<input type="radio" name="q16" value="3" />neutral
<input type="radio" name="q16" value="2" />disagree
<input type="radio" name="q16" value="1" />strongly disagree
<br />
<br />
5. The instructor explained concepts clearly
<br />
<input type="radio" name="q17" value="5" />strongly agree
<input type="radio" name="q17" value="4" />agree
<input type="radio" name="q17" value="3" />neutral
<input type="radio" name="q17" value="2" />disagree
<input type="radio" name="q17" value="1" />strongly disagree
<br />
<br />
6. The instructor made the elements of good writing clear
<br />
<input type="radio" name="q18" value="5" />strongly agree
<input type="radio" name="q18" value="4" />agree
<input type="radio" name="q18" value="3" />neutral
<input type="radio" name="q18" value="2" />disagree
<input type="radio" name="q18" value="1" />strongly disagree
<br />
<br />
7. The instructor clearly articulated the standards of performance for the course
<br />
<input type="radio" name="q19" value="5" />strongly agree
<input type="radio" name="q19" value="4" />agree
<input type="radio" name="q19" value="3" />neutral
<input type="radio" name="q19" value="2" />disagree
<input type="radio" name="q19" value="1" />strongly disagree
<br />
<br />
8. The instructor provided guidance for understanding course exercises
<br />
<input type="radio" name="q20" value="5" />strongly agree
<input type="radio" name="q20" value="4" />agree
<input type="radio" name="q20" value="3" />neutral
<input type="radio" name="q20" value="2" />disagree
<input type="radio" name="q20" value="1" />strongly disagree
</fieldset>
我希望能够在同一个多行文本框来显示每个结果对于每个问题,像这样,但它被课程和教授之间的问题分为:
课程
Q1:不同意
Q2:中性
Q3:中性
等等...
教授
Q1:不同意
Q2:中性
Q3:中性
等等...
第一:这是因为你还没有增加的Q值,
不正确,因为q是始终为1:
txtResults.Text = "Course Results";
if (results[i] == 1)
{
txtResults.Text += "Q" + q + ": Strongly Disagree";
}
其次,你允许的程序编写案例其中i = 0,I = 11
完整的答案:
public void DisplayResults(double[] results)
{
try
{
for (int i = 0, q = 1; i <= 19; i++, q++)
{
if (i == 0)
{
txtResults.Text += "Course Results";
}
if (i == 11)
{
txtResults.Text += "Professor Results";
}
txtResults.Text += "Q" + q ": ";
if (results[i] == 1)
{
txtResults.Text +="Strongly Disagree";
}
else if (results[i] == 2)
{
txtResults.Text +="Disagree";
}
else if (results[i] == 3)
{
txtResults.Text +=": Neutral";
}
else if (results[i] == 4)
{
txtResults.Text +="Agree";
}
else if (results[i] == 5)
{
if(i == 0 )
txtResults.Text +="Strongly Agree ZERO";
else if(i == 11 )
txtResults.Text +="Strongly Agree ELEVEN";
else
txtResults.Text +="Strongly Agree";
}
}
}
catch (Exception e)
{
Console.Write(e.Message, "Error");
}
}