J
J
I am having problems dynamically adding more than one event handler to
an input. I have tried the Javascript included at the bottom. The
lines
inp.attachEvent('onkeyup', makeEventFunc1(strand));
inp.attachEvent('onchange', makeEventFunc2(strand));
individually work in IE, but when used together, only the bottom one
remains active.
I have also tried
inp.onchange = new Function("nameclick(" + strand + ");");
inp.onkeyup = new Function("namechange(" + strand + ");");
but the code has problems in IE6. If I include one of the lines, it
will work in IE6. If I include both lines, neither event handler
works. All of the code works fine in Mozilla. Is there another way to
dynamically add two event handlers to a control that will work in IE?
Please help.
-Jason
function addNameRow(strand)
{
var tbody = document.getElementById("S" + strand +
"Names").getElementsByTagName("TBODY")[0];
var numnames = document.getElementById("S" + strand +
"NumNames");
numnames.value = parseInt(numnames.value)+ 1;
var row = document.createElement("TR");
td = document.createElement("TD");
td.className = 'sitetext';
td.innerHTML = "Enter Name #" + numnames.value + " for this
Strand (Optional)";
row.appendChild(td);
var n = "S" + strand + "Name" + numnames.value;
td1 = document.createElement("TD");
td1.id = "S" + strand + "NameRow" + numnames.value;
var inp = document.createElement("INPUT");
inp.size = 16;
inp.name=n;
inp.id=n;
if(inp.attachEvent)
{
//Do IE Specific
inp.attachEvent('onkeyup', makeEventFunc1(strand));
inp.attachEvent('onchange', makeEventFunc2(strand));
}
else
{
inp.onchange = new Function("nameclick(" + strand + ");");
inp.onkeyup = new Function("namechange(" + strand + ");");
}
td1.appendChild(inp);
row.appendChild(td1);
tbody.appendChild(row);
}
function makeEventFunc1( param1 )
{
return function()
{
nameclick(param1);
}
}
function makeEventFunc2( param1 )
{
return function()
{
namechange(param1);
}
}
an input. I have tried the Javascript included at the bottom. The
lines
inp.attachEvent('onkeyup', makeEventFunc1(strand));
inp.attachEvent('onchange', makeEventFunc2(strand));
individually work in IE, but when used together, only the bottom one
remains active.
I have also tried
inp.onchange = new Function("nameclick(" + strand + ");");
inp.onkeyup = new Function("namechange(" + strand + ");");
but the code has problems in IE6. If I include one of the lines, it
will work in IE6. If I include both lines, neither event handler
works. All of the code works fine in Mozilla. Is there another way to
dynamically add two event handlers to a control that will work in IE?
Please help.
-Jason
function addNameRow(strand)
{
var tbody = document.getElementById("S" + strand +
"Names").getElementsByTagName("TBODY")[0];
var numnames = document.getElementById("S" + strand +
"NumNames");
numnames.value = parseInt(numnames.value)+ 1;
var row = document.createElement("TR");
td = document.createElement("TD");
td.className = 'sitetext';
td.innerHTML = "Enter Name #" + numnames.value + " for this
Strand (Optional)";
row.appendChild(td);
var n = "S" + strand + "Name" + numnames.value;
td1 = document.createElement("TD");
td1.id = "S" + strand + "NameRow" + numnames.value;
var inp = document.createElement("INPUT");
inp.size = 16;
inp.name=n;
inp.id=n;
if(inp.attachEvent)
{
//Do IE Specific
inp.attachEvent('onkeyup', makeEventFunc1(strand));
inp.attachEvent('onchange', makeEventFunc2(strand));
}
else
{
inp.onchange = new Function("nameclick(" + strand + ");");
inp.onkeyup = new Function("namechange(" + strand + ");");
}
td1.appendChild(inp);
row.appendChild(td1);
tbody.appendChild(row);
}
function makeEventFunc1( param1 )
{
return function()
{
nameclick(param1);
}
}
function makeEventFunc2( param1 )
{
return function()
{
namechange(param1);
}
}