I'm trying to send the user selected date from the calendar to python but i'm seeing errors. Requirement is user selects a date from the calendar-->selected date sent to python -->SQL query retrieves the results from db using the date-->show the results back to user on webpage.
$(function() {
$( "#datepick" ).datepicker();
});
$(document).on("change", "#datepick", function () {
var newdate= $("#datepick").datepicker({ dateFormat: "dd-mm-yy"}).val();
alert(newdate);
$("#submitdate").submit();
});
This is the form I'm using :
<form id="submitdate" action="/date" method="POST">
<b>Date:</b> <input type="text" id="datepick" placeholder="Select Date">
</form>
After selecting the date from the calendar, i can see the selected date alert and once i click 'ok', the control is sent to new page(/date) but seeing the below error : The browser (or proxy) sent a request that this server could not understand.
Please suggest how to modify the code. I'm trying to capture this selected date in the python code : @app.route('/date',methods=['GET','POST']) def formval(): if request.method=='POST': dateval = request.form['datepick']