Hey folks,
So I had this developer who wrote up an “addElement” function for a dynamic form. The function worked well, however, I tried to add a function to the element and can’t get it working. Does anyone know how to get this working?
I tried to append the element as a child, to an element names “parentid”, defined as
<input id=”parentid” name=”parentid” type=”hidden”>
Here’s the function that I can’t get to work. We’re using alert() to just get this working, but have a different function to use later.
Many thanks beforehand for your time and patience in trying to help me out.
Also, if there is a better way for me to write this code and you have any suggestions, I’m all ears.
thanks,
-marco
[CODE]
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;
}