I’m trying to pass a value from html to a function but when I do I get an error – reference error: cant find the variable: “var value”. The code below I’m removing spaces and replacing them with underscores then trying to pass that to a function called onToDate.
var theFunction2 = theFunction.replace(/ /g,"_");
$('#inserted').append('<div id="'+theFunction2+'"><li onclick="onToDate('+theFunction2+')"><img width="30px" height="25px" src="style/soccer.png"><div id="popupContactClose2">'+counted+'</div></img>'+ rs.rows.item(0)['playing']+'</li>');
onToDate is simply there to alert the value passed to it:
function onToDate(hello){
alert(''+hello+'');
console.log(''+hello+'');
}
This is where I get the error. I don’t really get whats happening I’ve used this before and it worked fine.
Any help would be great,
Thanks
is turning into something like:
so in the above case,
some_thingis a variable that isundefined, meaning that this is a Reference error.So,
should fix it