简体   繁体   English

如何将表格中的选定行作为表单提交中的请求参数传递?

[英]How to pass selected rows from a table as request parameters on form submit?

I,m developing a web app(jsp) that extracts some data from a .doc file. 我正在开发一个Web应用程序(jsp),可从.doc文件中提取一些数据。 Headings from an uploaded document is extracted and listed in a table as below. 提取了上载文档的标题,并在下表中列出。

Generated output on upload-screenshot 在上传屏幕截图上生成的输出

I have added a check-box for each row. 我为每行添加了一个复选框。 Next what I want to do is save the check-box checked rows into an xml. 接下来,我要做的是将复选框选中的行保存到xml中。 I know how to write xml but how to do it only with the checked rows on form submit? 我知道如何编写xml,但如何仅使用表单提交中的选中行来做到这一点? My question summery is, How can I pass those checked rows from table on form submit as request parameters. 我的问题总结是,如何将表单上表格中的那些选中的行作为请求参数传递。 Thanks in advance. 提前致谢。

Creating checkbox array by keeping same name for all checkboxes will give you what you want. 通过为所有复选框保留相同的名称来创建复选框数组,将为您提供所需的内容。 In java, after submitting your form you read it in your servlet as 'request.getParameterValues("checkboxname")'. 在Java中,提交表单后,您在servlet中将其读为“ request.getParameterValues(“ checkboxname”)”。 you will get checked checkboxes from the array returned. 您将从返回的数组中获得选中的复选框。

HTML HTML

<table class="table">
<tr value="1" class="side-link">
    <td>one</td>
    <td>two</td>
</tr>
<tr value="2" class="side-link">
    <td>one</td>
    <td>two</td>
</tr>
</table>

JavaScript JavaScript的

$(".table").on('click','tr',function(e){
e.preventDefault();
var id = $(this).attr('value');
alert(id);
}); 

Demo 演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Angular 材料表:如何在按钮单击时传递/提交选定的行? - Angular Material Table: how to pass/submit selected rows upon button click? 如何在表单提交之前知道选定的数据表行 - How to know the selected datatable rows before form submit 如何提交表单并将一些额外的参数传递给$ .getJSON回调方法? - How to submit a form and pass some extra parameters to a $.getJSON callback method? 如何在Vue中提交表单,重定向到新路由并传递参数? - How to submit a form in Vue, redirect to a new route and pass the parameters? 如何通过jQuery或JavaScript将所选参数传递给表单操作URL - How to pass selected parameters to a form action url via jQuery or JavaScript 如何传递从HTML表单中选择的值? - How to pass valus selected from HTML Form? 如何将表格数据从PHP传递到javascript,以html形式显示它,点击提交按钮 - How to pass table data from PHP to javascript to display it in the html form onclick of a submit button 如何通过选择表单将参数传递给URL? - How to pass parameters to a URL from a select form? Tablesorter如何从表中删除选定的行 - Tablesorter how to remove selected rows from table 如何检查是否选择了表单选择以提交表单? - How to Check that a Form Selection is selected to submit the form?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM