【发布时间】:2021-01-06 10:32:47
【问题描述】:
我在下面的模板中有一个包含几列的 HTML 表格。表格的最后一列有一个按钮。代码如下。
index.html
<table id="deployment_table" class="table table-striped">
<thead>
<tr>
{% for col in colnames %}
<th>{{ col }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for record in records %}
<tr>
{% for col in colnames %}
<td>{{ record[col] }}</td>
{% endfor %}
<td class="td-actions text-right">
<a href=ct_edit ><input type="submit" name="edit_btn" value="update"rel="tooltip" class="btn btn-info"></a>
</input>
</td>
</tr>
{% endfor %}
</tbody>
</table>
当用户单击特定行的按钮时,我需要将所选行的第一列的值传递给 Flask 函数并使用此数据加载另一个 HTML 页面。
下面是flask后端函数。
@app.route('/ct_edit')
def ct_edit():
print('ct_edit')
# the value of the first column of the selected row => ID
# do something with the ID value and get a result
return render_template('ct_edit.html', result=result)
到目前为止,我无法完成这项工作。对此我有什么建议吗?
【问题讨论】: