我的页面如下,每点击一次“添加”按钮就生成一行表格,当所有信息输入完毕后点击“提交”按钮将值传给Action。如果行数已经确定的话可以在Action中通过get()方法来获取,但现在行数不确定,请教大家如何在Action中获取到这多行数据?
我的HTML代码如下:
- HTML code
<html><head><script type="text/javascript"> $().ready(function(){ //添加学生 $("#bt_add").click(function(){ var tr = $("#datalist table tbody:last-child"); //alert($("#datalist table tbody:last-child")()); $("#datalist table").append($(".trmodel").clone().show().removeClass()); }); $(".delete").live('click',function(){ $(this).parents("tr").animate({ opacity: 'hide', left:'+250px', top:'-120px' }, 1000); }); });</script></head><body> <div id="title"> <h2>添加学生</h2> <div> 入学年份 <select style="width:80px;"><option>2008</option></select> 系别 <select style="width:150px;"><option>计算机与科学系</option></select> 班级 <select style="width:150px;"><option>90812P</option></select> <span class="buttons"> <input type="button" value="提交" /> <input type="button" value="添加" id="bt_add" /> </span> </div> </div> <div style="clear:both;"></div> <!--表格样式--> <div id="datalist"> <table> <thead> <td width="20%">学号</td> <td width="20%">学生姓名</td> <td width="10%">性别</td> <td width="20%"></td> </thead> <tbody> <tr style=""> <td align="left"><input type="text" value="" /></td> <td align="left"><input type="text" value="" /></td> <td> <label> <input type="radio" name="RadioGroup1" value="男" id="RadioGroup1_0" checked="checked" class="input_align_5"/> 男</label> <label> <input type="radio" name="RadioGroup1" value="女" id="RadioGroup1_1" class="input_align_5" /> 女</label> </td> <td></td> </tr> <tr style=" display:none;" class="trmodel"> <td align="left"><input type="text" value="" /></td> <td align="left"><input type="text" value="" /></td> <td> <label> <input type="radio" name="RadioGroup1" value="男" id="RadioGroup1_0" checked="checked" class="input_align_5"/> 男</label> <label> <input type="radio" name="RadioGroup1" value="女" id="RadioGroup1_1" class="input_align_5" /> 女</label> </td> <td><a href="#" class="delete"> 删除</a></td> </tr> </tbody> </table> </div></body></html>