I have some code I copied from an example and I am not certain I understand it, and it is giving me an error that didn’t happen when I first used is.
On this page:
http://www.comehike.com/hikes/uncancel_hike.php?hike_id=30
I get the error: x is not defined on line 84
I am not too certain what x is supposed to be there. Any help appreciated, especially in helping me understand what is happening here 🙂
Here is the code:
function getCall(fn, param)
{
return function(e)
{
e = e || window.event;
e.preventDefault(); // this might let you use real URLs instead of void(0)
fn(e, param);
};
}
window.onload = function()
{
var a = document.getElementById("mylink");
a.onclick = getCall(deleteHike, x );
};
In your code here
xis a parameter that will be passed into the functiondeleteHikeand should be defined, or leftnullif you do not want a parameter, not knowing whatdeleteHikedoes here.Your code will wire up an event when the page is loaded to the element
myLink. When that element is clicked even info from the browser along with an extra parameter (x) will be passed into the function nameddeleteHike. Does that explain it?