python - 如何将选定表行中的值传递到我的后端
问题描述
在我的index.html
页面中,我有一个表格行:
<tr role="row" class="odd" style="color: rgb(0, 0, 0);">
<td hidden="" class="sorting_1">6</td>
<td>example_name</td>
<td>example_phone</td>
<td>example_email</td>
</tr>
index.html 中的表是使用 bootstrap 4 和 MDBootstrap 呈现的。
在浏览器中选择行后,<tr>
该类将其状态更改为tr-color-selected
:
<tr role="row" class="odd tr-color-selected" style="color: rgb(0, 0, 0);">
<td hidden="" class="sorting_1">6</td>
<td>example_name</td>
<td>example_phone</td>
<td>example_email</td>
</tr>
如何example_name, example_phone, example_email
将所选表格行的值传递给我的控制器views.py
?我在后端使用 Flask 和 SQLAlchemy。
编辑 #1 - 服务器端 javascript 代码
我正在使用 MDBootstrap 模态编辑器 ( https://mdbootstrap.com/docs/b4/jquery/plugins/table-editor/ ) 来呈现我的数据表:
<script>
$('#persons_table').mdbEditor({
modalEditor: true,
headerLength: 6,
});
$('.dataTables_length').addClass('bs-select');
</script>
这是我生成表格的代码:
<!-- table -->
<table id="persons_table" class="table table-sm table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th hidden class="th-sm">ID
</th>
<th class="th-sm">example_name
</th>
<th class="th-sm">example_phone
</th>
<th class="th-sm">example_email
</th>
</tr>
</thead>
<tbody>
{% for row in persons %}
<tr>
<td hidden>{{row.id}}</td>
<td>{{row.example_name}}</td>
<td>{{row.example_phone}}</td>
<td>{{row.example_email}}</td>
</tr>
{%- endfor %}
</tbody>
</table>
</div>
</div>
解决方案
推荐阅读
- flutter - Flutter - 小部件的状态没有改变
- regex - 正则表达式完全匹配
- firebase - Firebase:对删除规则的怀疑
- java - 如何创建提到的特定 JSON 格式
- swift - 如何修复 RealityKit/ARKit 中的“MakeRenderPipelineState failed”错误?
- visual-studio-code - 大型项目中的嵌套 vscode 设置?
- javascript - 开玩笑地使用 test.each 时跳过一些测试
- pynput - pyinstaller 让 pynput 很慢
- gcc - 让 gcc 链接器将多个函数放置在同一地址
- ios - IOS ipa文件显示白屏并卡在使用电缆运行时工作正常