急求助,怎么取画面动态表格的checkbox的值.
这是我的页面table ,其中的checkbox都是从数据库得数据来显示的,现在要把修改后的值保存,我试了request.getParameterValues(XX) ,这个方法只能取checked 了的box值 没checked的就没法取.求大神们给个方法啊
<table width="100%" class="table_border_bg" cellspacing="1" id="project_table">
<tr align="center">
<td class="list_title_bg" width="10%" rowspan="2"nowrap>期间</td>
<td class="list_title_bg" width="10%" rowspan="2"nowrap>公司</td>
<td class="list_title_bg" width="10%" rowspan="2"nowrap>项目名</td>
<td class="list_title_bg" width="10%" rowspan="2"nowrap>OS</td>
<td class="list_title_bg" width="10%" rowspan="2"nowrap>使用语言等</td>
<td class="list_title_bg" colspan="9" nowrap>职位(请在相应格内以"√"标示。)</td>
<td class="list_title_bg" width="5%" rowspan="2" nowrap>
<input type="button" class="button_bg" value="追 加" onclick="javascript:addProjectRow()"/>
</td>
</tr>
<tr align="center">
<td class="list_title_bg" width="5%" nowrap>管理</td>
<td class="list_title_bg" width="5%" nowrap>BI</td>
<td class="list_title_bg" width="5%" nowrap>BD</td>
<td class="list_title_bg" width="5%" nowrap>DD</td>
<td class="list_title_bg" width="5%" nowrap>PD</td>
<td class="list_title_bg" width="5%" nowrap>M/UT</td>
<td class="list_title_bg" width="5%" nowrap>SI</td>
<td class="list_title_bg" width="5%" nowrap>PT</td>
<td class="list_title_bg" width="5%" nowrap>RT</td>
</tr>
<imtag:repeat list="<%= getBean.getProjectList()%>" item="project" index="idx2" type="ResumeProject" >
<%
String projectRow = "projectRow"+idx2 ;
%>
<tr id="<%=projectRow %>">
<td class="list_data_bg" rowspan="1" nowrap align="center">
<input maxlength="4" type="text" style="width:30px" value="<%=project.getStartYear() %>" name="project_startYear"/>
年
<input maxlength="2" type="text" style="width:20px"value="<%=project.getStartMonth() %>"name="project_startMonth"/>
月 ~
<input maxlength="4" type="text" style="width:30px" value="<%=project.getEndYear() %>"name="project_endYear"/>
年
<input maxlength="2" type="text" style="width:20px" value="<%=project.getEndDate() %>"name="project_endMonth"/>
月
</td>
<td class="list_data_bg" rowspan="1" nowrap>
<input type="text" style="width:95%" value="<%=project.getCompanyName()%>"name="project_companyName"/>
</td>
<td class="list_data_bg" rowspan="1" nowrap>
<input type="text" style="width:95%" value="<%=project.getProjectName()%>"name="project_projectName"/>
</td>
<td class="list_data_bg" rowspan="1" nowrap>
<input type="text" style="width:95%" value="<%=project.getOperationSysterm()%>"name="project_oSystem"/>
</td>
<td class="list_data_bg" rowspan="1"nowrap>
<input type="text" style="width:95%" value="<%=project.getDevelopLanguage()%>"name="project_deveLanguage"/>
</td>
<td class="list_data_bg" rowspan="1" nowrap>
<input type="checkbox" value="managerFlag"<%=project.getManagerFlag()%> name="project_manFlag"/>
</td>
<td class="list_data_bg" rowspan="1" nowrap>
<input type="checkbox" value="biFlag"<%=project.getBiFlag()%> name="project_biFlag"/>
</td>
<td class="list_data_bg" rowspan="1" nowrap>
<input type="checkbox" value="bdFlag"<%=project.getBdFlag()%> name="project_bdFlag"/>
</td>
<td class="list_data_bg" rowspan="1" nowrap>
<input type="checkbox" value="ddFlag"<%=project.getDdFlag()%> name="project_ddFlag"/>
</td>
<td class="list_data_bg" rowspan="1" nowrap>
<input type="checkbox" value="pdFlag"<%=project.getPdFlag()%> name="project_pdFlag"/>
</td>
<td class="list_data_bg" rowspan="1" nowrap>
<input type="checkbox" value="mutFlag"<%=project.getMutFlag()%> name="project_mutFlag"/>
</td>
<td class="list_data_bg" rowspan="1" nowrap>
<input type="checkbox" value="siFlag"<%=project.getSiFlag()%> name="project_esiFlag"/>
</td>
<td class="list_data_bg" rowspan="1" nowrap>
<input type="checkbox" value="ptFlag"<%=project.getPtFlag()%> name="project_ptFlag"/>
</td>
<td class="list_data_bg" rowspan="1" nowrap>
<input type="checkbox" value="rtFlag"<%=project.getRtFlag()%> name="project_rtFlag"/>
</td>
<td class="list_data_bg" rowspan="1" nowrap>
<input type="button" class="button_bg" value="删 除" id="<%=projectRow %>"onclick="javascript:delRow('<%=idx2+1 %>')"/>
</td>
</tr>
</imtag:repeat>
</table>
[解决办法]
用jquery实现,js也行
[解决办法]
没看懂你的意思?
如果是想要所有checkbox的值,这个很简单
<script>function testByJs(){ var chkFlagObj=document.getElementsByName("chkFlag"); if(chkFlagObj){ for(var i=0;i<chkFlagObj.length;i++){ chkFlagObj[i].checked=!chkFlagObj[i].checked; } } //在提交form之前让这些checkbox全选中,然后在后台action里可以通过 //request.getParameterValues("chkFlag");取到所有选中的值}function testByJquery(){ $("[name='chkFlag']").attr("checked",'true');//全选}</script><body> <input type=checkbox name="chkFlag" value="1" />1 <br/> <input type=checkbox name="chkFlag" value="2" />2 <br/> <input type=checkbox name="chkFlag" value="3" />3 <br/> <input type=checkbox name="chkFlag" value="4" />4 <br/> <input type=checkbox name="chkFlag" value="5" />5 <br/> <input type=checkbox name="chkFlag" value="6" />6 <br/> <input type=checkbox name="chkFlag" value="7" />7 <br/> <hr2/> <input type=button onclick="testByJs()" value="select" /><br/></body>