我最近在做考试系统的时候 我在获取考生答案时出问题了:
问题是:我在显示单选题个判断题的时候 用的都是单选框:
在获取checked的时候
我想把这两类试题给区分一下 ,分别取值,然后我可以用ajax存库,我在用jquery的时候var allCheckValue = "";
$(":radio:checked").each(function () {
allCheckValue += $(this).val() + ",";
});
这样获取的是单选和判断的集合了 没办法把单选和判断试题的答案区别开 ???!!!!我的aspx代码
单选试题的代码
<asp:GridView ID="GridView1" runat="server" Width="100%" AutoGenerateColumns="False"
BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"
CellPadding="3">
<Columns>
<asp:TemplateField HeaderText="一、选择题">
<ItemTemplate>
<table id="table2" cellspacing="1" cellpadding="1" width="100%" align="center" border="0">
<br />
<tr>
<td colspan="3">
<asp:Label ID="Label1" runat="server" Text='<%# Container.DataItemIndex+1 %>'>
</asp:Label>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("ques_text") %>'>
</asp:Label>
</td>
</tr>
<tr>
<td width="35%">
A.<asp:RadioButton ID="A" GroupName="option" runat="server" Text='<%# Eval("choose_a") %>' />
<br />
</td>
<td width="35%">
B.<asp:RadioButton ID="B" GroupName="option" runat="server" Text='<%# Eval("choose_b") %>' />
<br />
</td>
<td>
</td>
</tr>
<tr>
<td width="35%">
C.<asp:RadioButton ID="C" GroupName="option" runat="server" Text='<%# Eval("choose_c") %>' />
<br />
</td>
<td width="35%">
D.<asp:RadioButton ID="D" GroupName="option" runat="server" Text='<%# Eval("choose_d") %>' />
</div>
</td>
<td>
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle Font-Size="12pt" HorizontalAlign="Left" />
</asp:GridView>
</td>
</tr>
html代码
<tr>
<td colspan="3">
<span id="GridView1_ctl02_Label1">1</span>
<span id="GridView1_ctl02_Label2">历史测试单选题1</span>
</td>
</tr>
<tr>
<td width="35%">
A.<input id="GridView1_ctl02_A" type="radio" name="GridView1$ctl02$option" value="A" /><label for="GridView1_ctl02_A">去</label>
<br />
</td>
<td width="35%">
B.<input id="GridView1_ctl02_B" type="radio" name="GridView1$ctl02$option" value="B" /><label for="GridView1_ctl02_B">去</label>判断试题的代码 <asp:GridView ID="GridView3" runat="server" Width="100%" AutoGenerateColumns="False"
BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"
CellPadding="3">
<Columns>
<asp:TemplateField HeaderText="三、判断题">
<ItemTemplate>
<table id="table4" cellspacing="1" cellpadding="1" width="100%" align="center" border="0">
<br />
<tr>
<td width="85%">
<asp:Label ID="Label19" runat="server" Text='<%# Container.DataItemIndex+1 %>'>
</asp:Label>
<asp:Label ID="Label20" runat="server" Text='<%# Eval("ques_text") %>'>
</asp:Label>
<asp:Label ID="Label7" runat="server" Text='<%# Eval("id") %>' Visible="False">
</asp:Label>
</td>
<td width="15%">
<asp:RadioButton ID="yes" GroupName="option" runat="server" Text="正确" />
<asp:RadioButton ID="no" GroupName="option" runat="server" Text="错误" />
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle Font-Size="12pt" HorizontalAlign="Left" />
</asp:GridView>html代码
<tr align="left" style="font-size:12pt;">
<th scope="col">三、判断题</th>
</tr><tr>
<td>
<table id="table4" cellspacing="1" cellpadding="1" width="100%" align="center" border="0">
<br />
<tr>
<td width="85%">
<span id="GridView3_ctl02_Label19">1</span>
<span id="GridView3_ctl02_Label20">历史测试判断题1</span>
</td>
<td width="15%">
<input id="GridView3_ctl02_yes" type="radio" name="GridView3$ctl02$option" value="yes" /><label for="GridView3_ctl02_yes">正确</label>
<input id="GridView3_ctl02_no" type="radio" name="GridView3$ctl02$option" value="no" /><label for="GridView3_ctl02_no">错误</label>
</td>
</tr>现在是
判断题
<input id="GridView3_ctl02_no" type="radio" name="GridView3$ctl02$option" value="no" /><label for="GridView3_ctl02_no">错误</label>单选题
A.<input id="GridView1_ctl03_A" type="radio" name="GridView1$ctl03$option" value="A" /><label for="GridView1_ctl03_A">的</label>用这个
allCheckValue = "";
$(":radio:checked").each(function () {
allCheckValue += $(this).val() + ",";
});
获取的时候 把单选和判断的搞一块了存库了,各位大侠有没有好的办法在获取的时候 能注明获取的类别 能把这两类试题给单独获取 并且单独的赋值 可以的话我可以追分的!!!谢谢
问题是:我在显示单选题个判断题的时候 用的都是单选框:
在获取checked的时候
我想把这两类试题给区分一下 ,分别取值,然后我可以用ajax存库,我在用jquery的时候var allCheckValue = "";
$(":radio:checked").each(function () {
allCheckValue += $(this).val() + ",";
});
这样获取的是单选和判断的集合了 没办法把单选和判断试题的答案区别开 ???!!!!我的aspx代码
单选试题的代码
<asp:GridView ID="GridView1" runat="server" Width="100%" AutoGenerateColumns="False"
BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"
CellPadding="3">
<Columns>
<asp:TemplateField HeaderText="一、选择题">
<ItemTemplate>
<table id="table2" cellspacing="1" cellpadding="1" width="100%" align="center" border="0">
<br />
<tr>
<td colspan="3">
<asp:Label ID="Label1" runat="server" Text='<%# Container.DataItemIndex+1 %>'>
</asp:Label>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("ques_text") %>'>
</asp:Label>
</td>
</tr>
<tr>
<td width="35%">
A.<asp:RadioButton ID="A" GroupName="option" runat="server" Text='<%# Eval("choose_a") %>' />
<br />
</td>
<td width="35%">
B.<asp:RadioButton ID="B" GroupName="option" runat="server" Text='<%# Eval("choose_b") %>' />
<br />
</td>
<td>
</td>
</tr>
<tr>
<td width="35%">
C.<asp:RadioButton ID="C" GroupName="option" runat="server" Text='<%# Eval("choose_c") %>' />
<br />
</td>
<td width="35%">
D.<asp:RadioButton ID="D" GroupName="option" runat="server" Text='<%# Eval("choose_d") %>' />
</div>
</td>
<td>
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle Font-Size="12pt" HorizontalAlign="Left" />
</asp:GridView>
</td>
</tr>
html代码
<tr>
<td colspan="3">
<span id="GridView1_ctl02_Label1">1</span>
<span id="GridView1_ctl02_Label2">历史测试单选题1</span>
</td>
</tr>
<tr>
<td width="35%">
A.<input id="GridView1_ctl02_A" type="radio" name="GridView1$ctl02$option" value="A" /><label for="GridView1_ctl02_A">去</label>
<br />
</td>
<td width="35%">
B.<input id="GridView1_ctl02_B" type="radio" name="GridView1$ctl02$option" value="B" /><label for="GridView1_ctl02_B">去</label>判断试题的代码 <asp:GridView ID="GridView3" runat="server" Width="100%" AutoGenerateColumns="False"
BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"
CellPadding="3">
<Columns>
<asp:TemplateField HeaderText="三、判断题">
<ItemTemplate>
<table id="table4" cellspacing="1" cellpadding="1" width="100%" align="center" border="0">
<br />
<tr>
<td width="85%">
<asp:Label ID="Label19" runat="server" Text='<%# Container.DataItemIndex+1 %>'>
</asp:Label>
<asp:Label ID="Label20" runat="server" Text='<%# Eval("ques_text") %>'>
</asp:Label>
<asp:Label ID="Label7" runat="server" Text='<%# Eval("id") %>' Visible="False">
</asp:Label>
</td>
<td width="15%">
<asp:RadioButton ID="yes" GroupName="option" runat="server" Text="正确" />
<asp:RadioButton ID="no" GroupName="option" runat="server" Text="错误" />
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle Font-Size="12pt" HorizontalAlign="Left" />
</asp:GridView>html代码
<tr align="left" style="font-size:12pt;">
<th scope="col">三、判断题</th>
</tr><tr>
<td>
<table id="table4" cellspacing="1" cellpadding="1" width="100%" align="center" border="0">
<br />
<tr>
<td width="85%">
<span id="GridView3_ctl02_Label19">1</span>
<span id="GridView3_ctl02_Label20">历史测试判断题1</span>
</td>
<td width="15%">
<input id="GridView3_ctl02_yes" type="radio" name="GridView3$ctl02$option" value="yes" /><label for="GridView3_ctl02_yes">正确</label>
<input id="GridView3_ctl02_no" type="radio" name="GridView3$ctl02$option" value="no" /><label for="GridView3_ctl02_no">错误</label>
</td>
</tr>现在是
判断题
<input id="GridView3_ctl02_no" type="radio" name="GridView3$ctl02$option" value="no" /><label for="GridView3_ctl02_no">错误</label>单选题
A.<input id="GridView1_ctl03_A" type="radio" name="GridView1$ctl03$option" value="A" /><label for="GridView1_ctl03_A">的</label>用这个
allCheckValue = "";
$(":radio:checked").each(function () {
allCheckValue += $(this).val() + ",";
});
获取的时候 把单选和判断的搞一块了存库了,各位大侠有没有好的办法在获取的时候 能注明获取的类别 能把这两类试题给单独获取 并且单独的赋值 可以的话我可以追分的!!!谢谢
A.<asp:RadioButton CssClass="choose" ID="A" GroupName="option" runat="server" Text='<%# Eval("choose_a") %>' />
$(".choose :radio:checked").each(function () {
allCheckValue += $(this).val() + ",";
});
判断题给个不一样的Class
你试试看行不行
不过我这还与一个问题:
//aspx代码
A<asp:CheckBox ID="CheckBox1" runat="server" value="A" Text='<%# Eval("mchoose_a") %>'>
</asp:CheckBox>
//html代码
i<input id="GridView2_ctl03_CheckBox8" type="checkbox" name="GridView2$ctl03$CheckBox8" /><label for="GridView2_ctl03_CheckBox8">4 </label>
//jqury代码
var allCheckValue = "";
//$(":checkbox:checked").each(function () {
$("input[type='checkbox']:checked").each(function () {
allCheckValue += $(this).val() + ",";
});我获取的数值存进数据库的时候 都是 on,on 全部是on 不是数值
我在获取的 有问题吗 应该怎么整啊 非常感谢很感谢 !!!