最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - submit django form on checkbox select - Stack Overflow

programmeradmin6浏览0评论

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")
发布评论

评论列表(0)

  1. 暂无评论