PDA

View Full Version : parameter myDIVnode.firstChild.nodeValue not passed to function


BubikolRamios
10-01-2006, 08:31 AM
why this parameter is not passed to function ?



var myDIVnode1 = document.createElement("DIV");
// etc
myDIVnode1.appendChild(document.createTextNode("a"));
// this shows "a"
alert(myDIVnode1.firstChild.nodeValue);

myDIVnode1.onclick= function() { somefunc(myDIVnode.firstChild.nodeValue); };

function somefunc(param)
{
// this returns "undefined" !!??
alert(param);
}

syosoft
10-01-2006, 09:56 AM
perhaps a typo?


// Change
myDIVnode1.onclick= function() { somefunc(myDivNode.firstChild.nodeValue);

// To
myDIVnode1.onclick= function() { somefunc(myDivNode1.firstChild.nodeValue);


Notice the 1 after myDivNode not present in your code.

BubikolRamios
10-01-2006, 09:59 AM
yes typo. Will prowide sample and link ...

syosoft
10-01-2006, 10:02 AM
So that wasnt the problem?

BubikolRamios
10-01-2006, 10:59 AM
ahh sorry, the bug was somewhere else

in real case I had:



function somefunc(param1,param2)
{
// tons of stuff (-: ....
alert(param3);
}



didn't see that there is no param3, although I did send 3 params to func. Hmm.

Thanks for help.