Feb 27, 2023
1
Level 1
Javascript variable comes null even though it has one
Hello im using javascript to add parameters to an url, this is my code what i have done until now:
var startdate = document.getElementById("startdateOutlay"); var enddate = document.getElementById("enddateOutlay");
alert(startdate.value);
const apiUrl = `http://127.0.0.1:8000/api/outlay?startdate=${startdate.value}&enddate=${enddate.value}`;
the alert brings me the value correct but then on the url i get this error:
Uncaught (in promise) TypeError: startdate is null
Please or to participate in this conversation.