我现在要做一个在线考试系统,但是在处理学生考试界面这里遇到了困难,考试页面中有四种类型的题目,每种题目有好几道题。如何将这些学生选择的答案和题目id保存成json字符串呢,这个json字符串应该如何传递给后台的cs文件,由谁进行处理呢?
<div style="visibility: visible;" tabindex="-1" class="div_question div_question_mouseout"> <div class="div_preview"> <div class="div_title_question_all"> <div class="div_topic_question">1.</div> <div class="div_title_question"><span>这是第455题</span></div> <div style="clear: both;"></div> </div> <div class="div_table_radio_question"> <div class="div_table_clear_top"></div> <ul> <li style="width: 99%;"> <input id="question" name="4573" type="radio">这是第455题的第0个选项</li> <li style="width: 99%;"> <input id="Radio1" name="4573" type="radio">这是第455题的第1个选项</li> <li style="width: 99%;"> <input id="Radio2" name="4573" type="radio">这是第455题的第2个选项</li> <li style="width: 99%;"> <input id="Radio3" name="4573" type="radio">这是第455题的第3个选项</li> </ul> </div> </div> </div> <div style="visibility: visible;" tabindex="-1" class="div_question div_question_mouseout"> <div class="div_preview"> <div class="div_title_question_all"> <div class="div_topic_question">1.</div> <div class="div_title_question"><span>这是第2097题</span></div> <div style="clear: both;"></div> </div> <div class="div_table_radio_question"> <div class="div_table_clear_top"></div> <ul> <input name="2097" value="true" type="radio"> 正确 <br> <input name="2097" value="false" type="radio"> 错误 <div style="clear: both;"></div> </ul> <div class="div_table_clear_bottom"></div> </div> </div> </div> <div style="visibility: visible;" tabindex="-1" class="div_question div_question_mouseout"> <div class="div_preview"> <div class="div_title_question_all"> <div class="div_topic_question">1.</div> <div class="div_title_question"><span>这是第1736题</span></div> <div style="clear: both;"></div> </div> <div class="div_table_radio_question"> <div class="div_table_clear_top"></div> <ul> <input id="Text1" type="text"> <div style="clear: both;"></div> </ul> <div class="div_table_clear_bottom"></div> </div> </div> </div> <div style="visibility: visible;" tabindex="-1" class="div_question div_question_mouseout"> <div class="div_preview"> <div class="div_title_question_all"> <div class="div_topic_question">1.</div> <div class="div_title_question"><span>这是第3717题</span></div> <div style="clear: both;"></div> </div> <div class="div_table_radio_question"> <div class="div_table_clear_top"></div> <ul> <textarea class="inputtext" style="width: 62%; height: 90px; overflow: auto;" rows="1" wrap="soft"></textarea> <div style="clear: both;"></div> </ul> <div class="div_table_clear_bottom"></div> </div> </div> </div>
我之前有实现过一个这东西,
基本思路是,前台维护一个json数组,注册所有题目的点击事件,答题时修改json数组中的值,提交时提交json到后台,序列化成一个答案对象集合,就能搞定
前台的Json数组这里是如何实现的呢?可以给我些代码参考一下吗?
@羽商宫: 前台JSON数组直接var arr=@(序列化的json字符串)
就能把字符串输出到前台了
@吴瑞祥: 我就是不知道如何将这些div中的数据变成json数组。请问如何将前台div循环遍历一下,生成一个json数组呢?
@羽商宫: DIV中的数据不是你在后台输出的吗.
你后台就应该会有这些题目对应的对象是吧.然后根据这个对象集合输出一个JSON到页面上
不用在前台遍历,直接在后台生成DIV的同时生成一个JSON字符串,一起输出到前台