My HTML has a button that runs a function that calls several other JavaScript functions. It looks like this:
<button id="ButtonSearch" onclick="FillAll()"></button>
The function FillAll() is in file Calls.js and looks like this:
function FillAll()
{
var from_date = document.getElementById('FromDate').value;
var to_date = document.getElementById('ToDate').value;
FillMap();
FillMap(from_date, to_date);
FillRadio();
FillArea();
}
And finally, the actual function FillMap(), which is in file Maps.js and looks like this:
function FillMap(from_date, to_date)
{
alert(from_date);
var from_date = document.getElementById('FromDate').value;
var to_date = document.getElementById('ToDate').value;
// do stuff
}
The odd thing is that FillMap() is being called twice, and the alert pops up twice: the first one is undefined while the second one shows from_date.
Generally speaking, are JavaScript functions different to "regular" functions where the number of arguments would need to match?
In this case, the arguments don't match but the function is still being called.
void(0). While it works, it's an ancient technique. The better choice is to simply passnullfor the argument value.