javascript:
$("#id_report").on('change', function() {
var reportform = document.getElementById("status-form");
var live = document.getElementById("id_report");
if (live.checked == true){
reportform.submit();
}
});
表格.py
class Reportform(Form):
report = forms.BooleanField(widget=forms.CheckboxInput(),required=False, label="Report",initial=True)
模板.html
<form action="." id="status-form" method="POST">{% csrf_token %}
<p>{{closedreport.report}}Show Reports</p>
</form>
如果复选框被选中,我想提交表单。默认情况下,复选框被选中,但表单没有被提交。