javascript - Django - How to make datepicker submit form on change -



javascript - Django - How to make datepicker submit form on change -

so have jquery datepicker in html, shown below:

<form id="form" method="get" action="."> ... <input class="form-control" type="text" value="{{ range }}" name="range" placeholder="date range" id="daterange"><b class="caret"></b></input> </form>

and javascript function makes datepicker:

$(document).ready(function() { $("#daterange").daterangepicker({ ranges: { "today": [new date(), new date()], "yesterday": [moment().subtract("days", 1), moment().subtract("days", 1)], "last week": [moment().subtract("days", 6), new date()], "last 30 days": [moment().subtract("days", 29), new date()], "this month": [moment().startof("month"), moment().endof("month")], "last month": [moment().subtract("month", 1).startof("month"), moment().subtract("month", 1).endof("month")], "max": [moment("jan 1, 2014"), new date()], }, opens: "right", onselect: function(date, instance) { alert('test'); }, format: "yyyy-mm-dd", startdate: new date(), enddate: new date(), }, function(start, end) { $("#daterange span").html(start.format("mmm d, yyyy") + " - " + end.format("mmm d, yyyy")); } ); });

how submit form automatically when datepicker value changed?

btw: have tried onchange="" , onselect: function {}, , both not work.

form.html

<form id="form_id" method="get" action="."> ... <input class="form-control" type="text" value="{{ range }}" name="range" placeholder="date range" id="daterange"><b class="caret"></b></input> </form>

check should work,

$(document).ready(function() { $("#daterange").daterangepicker({ ranges: {}, opens: "right", onselect: function() {},//remove 1 function(start, end) {}, onchange: function(){ $("#form_id").submit();} //add line });

javascript jquery django datepicker

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -