admin管理员组

文章数量:1401158

tml:

<div id="report-liveonly">
  <form action="." id="status" method="POST">{% csrf_token %}
  <p>{{SearchKeywordForm.status}}Only show LIVE reports</p>
  </form>
</div>

I am trying to submit the searchform on checkbox click.It is not working. Onclick also not happening,i checked with alert message.

The total function is to show the live report,if Only show LIVE reports checkbox is checked.

Need help

tml:

<div id="report-liveonly">
  <form action="." id="status" method="POST">{% csrf_token %}
  <p>{{SearchKeywordForm.status}}Only show LIVE reports</p>
  </form>
</div>

I am trying to submit the searchform on checkbox click.It is not working. Onclick also not happening,i checked with alert message.

The total function is to show the live report,if Only show LIVE reports checkbox is checked.

Need help

Share Improve this question edited Jul 24, 2013 at 10:29 user2086641 asked Jul 19, 2013 at 8:20 user2086641user2086641 4,37115 gold badges59 silver badges96 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 9

I found the solution,

class SearchKeyword(Form):
    search_keyword = forms.CharField(widget=forms.TextInput(attrs={'placeholder': 'Keyword Search','class':'keyword-search'}))
    status = forms.BooleanField(widget=forms.CheckboxInput(attrs={'onclick':'this.form.submit();'}),required=False, label="Status")

本文标签: javascriptsubmit django form on checkbox selectStack Overflow