こんにちは私はアイテムのリストを表示するテンプレートフォームを持っています。このテンプレートはedit_order.htmlと呼ばれます。別のアイテムリストから新しいアイテムを追加できるようにしたい。他のアイテムのリストからはitems.htmlというテンプレートがあり、アイテムのリストが表示されます。 items.htmlでは、各項目には項目の横にチェックボックスがあります。さて、私がしたいのは、アイテムが既にedit_orderテンプレートにリストされている場合にのみ、チェックボックスをマークすることです。現在、すべての商品にはマークが付けられています。私はこれを望んでいません。Djangoのチェックボックスの質問
{% extends "base_menu.html" %}
{%block script%}
<script type="text/javascript">
$(function(){
$("#check_all").click(function(){
if(this.checked ==true)
$("tbody :checkbox").each(function(){
this.checked=true;
});
else
$("tbody :checkbox").each(function(){
this.checked=false;
});
});
});
</script>
{%endblock%}
<td><a href="{% url tiptop.views.edit_item item.client.pk item.pk %}" onclick="return showAddAnotherPopup(this);">Edit</a></td>
</tr>
{% endfor %}
</tbody>
</table></fieldset>
</div>
<div id="form_footer">
<input type="submit" value="Request Delivery" onclick="change_action('{% url tiptop.views.service_order client.pk 1 %}')">
<input type="submit" value="Request Pick Up" onclick="change_action('{% url tiptop.views.service_order client.pk 2 %}');validate_status(this.form)">
</div>
</form>
{% endblock %}
{% block right_content %}
<div id="location_header">{{client}}: Search results</div>
<form action="{% url tiptop.views.service_order client.pk 1 %}" method="post" onsubmit="return validate_selection(this)">
<div class="form_container">
<fieldset class="model">
<table id="items_table">
<thead>
<tr>
<th><input type="checkbox" id="check_all" checked="checked"></th>
<th scope="col">Tiptop no.</th><th scope="col">Client no.</th><th scope="col">Title</th><th scope="col">Type</th>
<th scope="col">Format</th><th scope="col">Status</th><th scope="col">Date</th>
</tr>
</thead>
<tbody>
{% for item in items %}
<tr class="items_table_row">
<td><input type="checkbox" name="{{item.pk}}" value="{{item.pk}}" checked="checked"></td>
<td>{{item.tiptop_id}}</td><td>{{item.alternative_id}}</td><td>{{item.title}}</td><td>{{item.type}}</td><td>{{item.format}}</td>
<td><span id="{{item.pk}}" name="type">{{item.itemstatushistory_set.latest}}</span></td><td>{{item.itemstatushistory_set.latest.date.date|date:"d M Y"}}</td>
私はdjangoフォームを使用しています。私は私の意見をアップロードしていない。私はすでにチェックリストを持っています。私はアイテムをリストするテンプレートを持っています。このテンプレートからは、アイテムを追加できます。今ではアイテムを追加することを意味するとき、私はフォームを作成することを意味しません。つまり、既存のすべてのクライアントアイテムをリストするページに移動します(このテンプレートがあります)。このテンプレートには、追加する既存のアイテムを選択できるリストがあります。私が問題を抱えているのは、チェックボックスです。彼らは何らかの理由で私のコードの中ですべて「刻まれている」。テンプレート項目リストの項目にチェックを入れ、空白にします。 – Shehzad009