I have a JavaScript function within a JavaScript function. The JavaScript below inserts some HTML in a div using getElementbyID.
It is passing one variable okay--that seems to be a child of an object, this.value--btw, I am a JavaScript newb, however, when I try to give it another variable to pass, the string represented by l it stops working. Below type 1 which tries to pass variable l does not work, else, does. I have also just tried putting l '+ but that did not work. Can anyone help me with proper syntax for passing variables?. Thank you.
if (type==1)
{
var mailbox = '<form action="mail.php" method="post"><input type="text" onkeyup="showResult(this.value,'+l+')"><input type="submit" name="submit" value="Email"><div id="livesearch"></div></form>';
}
else
{
var mailbox = '<form action="share.php" method="post"><input type="text" onkeyup="showResult(this.value)"> Share<div id="livesearch"></div></form>';
}
document.getElementById(target).innerHTML = mailbox;
return false;
}
l?lcan contain?l = "foo bar"then the function call becomesshowResult(this.value,foo bar).