【发布时间】:2017-04-24 03:08:02
【问题描述】:
在我的 Django 项目中,我为所有客户提供了一个列表页面。 在所有客户列表显示的那个页面上,我在那里有一个归档 is_active 。 如果我单击更改状态按钮(客户列表页面的每一行都有一个更改状态按钮)is_active 字段变为假而不重新加载我的列表页面。当我再次单击更改状态按钮时它变为 True。请帮助我提供它的示例代码。 我的listing页面如下-
<!DOCTYPE html>
<html>
<head>
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
tr:nth-child(even) {
background-color: #dddddd;
}
</style>
</head>
<body>
<form id="myform" method = "POST" action="#">
<table>
<tr>
<th>Name</th>
<th>Location</th>
<th>quantity</th>
<th>time</th>
<th>fb_id</th>
<th>contact_number</th>
<th>is_active</th>
<th>Action</th>
</tr>
{% for lead in leads %}
<tr>
<td>{{lead.customer_name}}</td>
<td>{{lead.location}}</td>
<td>{{lead.quantity}}</td>
<td>{{lead.time_requirement}}</td>
<td>{{lead.fb_id}}</td>
<td>{{lead.contact_number}}</td>
<td>
{% if lead.is_active %}
<input type="radio" value="" checked>
{% else %}
<input type="radio" value="" >
{% endif %}
<button name="button" value="OK" type="button" >change status</button>
</td>
<td><button name="button" value="OK" type="button" align="middle"><a href="/customapi/vendor/detail-customer-leads/?lead_id={{lead.id}}">Edit</a></button>
</td>
</tr>
{% endfor %}
</table>
</form>
</body>
</html>
【问题讨论】:
标签: javascript html css ajax django