F
fusillo
My code pass a value of a variable to the event handler's argument by
means of eval statement
here's:
//statements setting evt
for (var i=0; i<evt.periodi.length; i++){
//evt.periodi is an array of objs
a=document.createElement("a");
a.onclick=eval('function (){ cancellaCal(' + evt.periodi.id_evt_cal
+ '); };');
a.appendChild(document.createTextNode("cancella"));
//another statements
}
Without eval trick evt.periodi.id_evt_cal is undefined within handler
function.
Is there a better solution?
Thanks
fusillo
means of eval statement
here's:
//statements setting evt
for (var i=0; i<evt.periodi.length; i++){
//evt.periodi is an array of objs
a=document.createElement("a");
a.onclick=eval('function (){ cancellaCal(' + evt.periodi.id_evt_cal
+ '); };');
a.appendChild(document.createTextNode("cancella"));
//another statements
}
Without eval trick evt.periodi.id_evt_cal is undefined within handler
function.
Is there a better solution?
Thanks
fusillo