I am new to using JS to pass data to Python. I have managed to collect the values when the HTML is loaded, but I am facing an issue where the value does not change when it is updated.
Here is the code snippet that I have been working with:
<input type="date" id="start-date" name="start-date" value="2019-10-10"/>
<label for="date">to</label>
<input type="date" id="end-date" name="end-date" value="2020-05-10"/>
<script>
document.onreadystatechange = function () {
var start_date = document.getElementById("start-date").value;
var end_date = document.getElementById("end-date").value;
$.ajax({
url: "/dates",
type: "GET",
data: {
start_date: start_date,
end_date: end_date,
},
});
};
</script>