在 Freemarker 模板语言中单击(选中)复选框时从 table 发送两个值
Send two values from table when a checkbox is clicked (checked) in Freemarker Template Language
<#if userDatas?? >
<form action="remove-list" method="POST" autocomplete="on" class="form-horizontal" role="form" id="form1">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th class="minwidth">select All <input type="checkbox" onchange="checkAll(this)"> </th>
<th>roll no</th>
<th>name</th>
<th>Created date</th>
<th>modified date</th>
</tr>
</thead>
<tbody>
<#list userDatas as userData>
<tr>
<td class="centered-simple"><input type="checkbox" name="entries" value="${userData.roll}" id="${userData.roll}" ></td>
<td>${(userData.roll)!notset}</td>
<td>${(userData.name)!notset}</td>
<td>${(userData.whenCreated?datetime)!notset}</td>
<td><code>${(userData.whenModified?datetime)!notset}</code></td>
</tr>
</#list>
</tbody>
</table>
<div class="btn-group btn-group-tss">
<button type="submit" class="btn btn-primary">
<span class="glyphicon glyphicon-search"></span> Delete selected
</button>
</div>
</form>
</#if>
在上面的代码片段中,我有一个 table,标题为 select 所有,角色,名称,创建日期和修改日期。
当我点击删除selected按钮时,显然userdata.roll值将被发送。
这里我想在点击复选框时同时发送 userdata.roll 和 userdata.name。
我尝试了但没成功。
请帮助我如何在选中复选框时发送这两个值。
PS : 我正在使用 FTL 来编码。
不止一个table这是一个表单,而"Delete selected"按钮是一个提交按钮。提交表单后,将发送所有输入(张贴在您的案例中)。
您可以在表单的任意位置添加隐藏字段
<input type="hidden" name="someParamNameHere" value="${userData.name}" />
如果您只想在单击复选框时发送此值,您可以添加一些基本的 javascript。但是我建议你把逻辑放在服务器端。
<#if userDatas?? >
<form action="remove-list" method="POST" autocomplete="on" class="form-horizontal" role="form" id="form1">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th class="minwidth">select All <input type="checkbox" onchange="checkAll(this)"> </th>
<th>roll no</th>
<th>name</th>
<th>Created date</th>
<th>modified date</th>
</tr>
</thead>
<tbody>
<#list userDatas as userData>
<tr>
<td class="centered-simple"><input type="checkbox" name="entries" value="${userData.roll}" id="${userData.roll}" ></td>
<td>${(userData.roll)!notset}</td>
<td>${(userData.name)!notset}</td>
<td>${(userData.whenCreated?datetime)!notset}</td>
<td><code>${(userData.whenModified?datetime)!notset}</code></td>
</tr>
</#list>
</tbody>
</table>
<div class="btn-group btn-group-tss">
<button type="submit" class="btn btn-primary">
<span class="glyphicon glyphicon-search"></span> Delete selected
</button>
</div>
</form>
</#if>
在上面的代码片段中,我有一个 table,标题为 select 所有,角色,名称,创建日期和修改日期。
当我点击删除selected按钮时,显然userdata.roll值将被发送。
这里我想在点击复选框时同时发送 userdata.roll 和 userdata.name。
我尝试了但没成功。
请帮助我如何在选中复选框时发送这两个值。
PS : 我正在使用 FTL 来编码。
不止一个table这是一个表单,而"Delete selected"按钮是一个提交按钮。提交表单后,将发送所有输入(张贴在您的案例中)。
您可以在表单的任意位置添加隐藏字段
<input type="hidden" name="someParamNameHere" value="${userData.name}" />
如果您只想在单击复选框时发送此值,您可以添加一些基本的 javascript。但是我建议你把逻辑放在服务器端。