【发布时间】:2018-06-08 06:25:30
【问题描述】:
案例:
我的数据库中有一个表,其中每一行都包含一个 form 类型的值,并且在行尾有一个保存按钮。
现在我想做的事情如下:
当我单击保存按钮时,必须打开一个模式弹出窗口,它应该显示单击保存按钮的行中存在的数据。
此外,模式将有两个按钮提交和取消。 如果我点击模型上的保存按钮,数据必须在后端发送(我使用 Django 作为后端)。
我该怎么做?
我们将不胜感激。
代码:
{% block content %}
<table id ="devicetable" cellpadding="20%" style="width:100%">
<thead>
<tr>
{% for column in columns %}
<td>{{ column }}</td>
{% endfor %}
{% if type != "NReq" %}
<td> Button </td>
{% endif %}
</tr>
</thead>
{% for a in all %}
<tr>
<form action = {% url type %} method="POST">{% csrf_token %}
{% for k in columns %}
<td>{{ a|get_item:k }}<input type = "hidden" name = {{k}} value = "{{ a|get_item:k }}"></td>
{% endfor %}
{% if type != "NReq" %}
<td> <button type="submit" class="btn btn-primary">{{type}}</button></td>
{% endif %}
</form>
</tr>
{% endfor %}
</table>
{% endblock %}
【问题讨论】:
标签: javascript html django-forms bootstrap-modal