M
Marco
Hey folks,
Really could use some advice on a function. The code works fine in
creating the element, however, the associated function to the
dynamically added element doesn't run. If you can suggest a way to fix
this or a better way to code this function, I'd really be
appreciative. I've been struggling with all different things. I even
tried defining a parentid as <input id="parentid" name="parentid"
type="hidden"> and appending a child. It didn't work.
Any thoughts?
thanks,
-m
function addFormField1(a,b) {
var id = document.getElementById("id").value;
$("#div" + a + "").append("<p id='row" + id + "'><label for='txt" +
id + "'> <input type='text' size='43' onkeyup='alert('" +
a + "" + id + "');' name='" + a + "[]' id='" + a + "" + id +
"'> <a href='#' onClick='removeFormField1(\"#row" + id + "\");
return false;'><img src='images/01_03.gif' border='0' ></a><p>");
$('#row' + id).highlightFade({speed:1000});
//document.getElementById("parentid").appendChild("'"+ a + "" + id
+"'");
id = (id - 1) + 2;
document.getElementById("id").value = id;
}
Really could use some advice on a function. The code works fine in
creating the element, however, the associated function to the
dynamically added element doesn't run. If you can suggest a way to fix
this or a better way to code this function, I'd really be
appreciative. I've been struggling with all different things. I even
tried defining a parentid as <input id="parentid" name="parentid"
type="hidden"> and appending a child. It didn't work.
Any thoughts?
thanks,
-m
function addFormField1(a,b) {
var id = document.getElementById("id").value;
$("#div" + a + "").append("<p id='row" + id + "'><label for='txt" +
id + "'> <input type='text' size='43' onkeyup='alert('" +
a + "" + id + "');' name='" + a + "[]' id='" + a + "" + id +
"'> <a href='#' onClick='removeFormField1(\"#row" + id + "\");
return false;'><img src='images/01_03.gif' border='0' ></a><p>");
$('#row' + id).highlightFade({speed:1000});
//document.getElementById("parentid").appendChild("'"+ a + "" + id
+"'");
id = (id - 1) + 2;
document.getElementById("id").value = id;
}