Hi all,
I’ve never done this type of coding before, and so far every snippet I’ve found on Google has failed to work.
I have a function that created a new element for which I’m trying to set the onClick and onBlur events. The events should call a function once triggered. Not only do I need to construct the function, but also pass parameters to it from within the parent function.
Here’s my code so far:
[CODE]
function TextOut(txtID,defaultText,isPass)
{
var myBox = document.getElementById(txtID);
//alert(myBox.value);
if (myBox.value == “”)
{
myBox.value = defaultText;
if (isPass == “yes”)
{
var msie = ((navigator.appVersion.indexOf(“MSIE”)!= -1)&&!window.opera)? true : false;
if (msie)
{
//var np=myBox.cloneNode(true);
//np.type=”text”;
//np.value = defaultText
//myBox.parentNode.replaceChild(np,myBox);
var np = document.createElement(“input”)
np.name=txtID;
np.id=txtID;
np.value=defaultText;
[COLOR=”Red”][B]np.setAttribute(“onClick”,”TextOver(‘” + txtID + “‘,'” + defaultText + “‘,'” + isPass + “‘);”)
np.setAttribute(“onBlur”,”TextOut(‘” + txtID + “‘,'” + defaultText + “‘,'” + isPass + “‘);”)[/B][/COLOR]
np.className = “font textbox”;
myBox.parentNode.replaceChild(np,myBox);
myBox = null;
myBox = np;
alert(“Mybox=” + myBox.onClick + ” / np =” + np.onClick);
}
if (!(msie))
{
myBox.type = “text”
}
}
}
}
Thanks in advance for any ideas/advice.
ZS
PS: The code generates no errors. Simply nothing is triggered when the newly created element is acted upon — which leads me to believe that the function call is not being properly embedded.