accessing field value after append.
I am hoping someone can help me with this problem. I am using append to add a row with several
cells to a table. These cells contain form fields one of which has a value.
$.get(url, function(data){
$('#fieldContainer').append(data);
This appears to work fine. When I highlight the new row in the browser and view the source it shows all of the data that is supposed to be there including one field with a stored value.
My problem is I tried to add a javascript validation to the function that will check to make sure that the
name I am adding hasn't already been used. To do this I iterate through each row and compare my new
value with the ones that are there. When it gets to one of the new appended rows it shows the value
as undefined.
Does anyone know why this is happening and what I need to do to make them accessible.
Thanks
David
var numberOfFields = $("#numberOfFields").val() ;
numberOfFields = parseInt(numberOfFields);
for (i=0; i < numberOfFields; i++) {
var thisFieldName = 'fieldName'+ i;
thisFieldName = $('input[name=' + thisFieldName + ']').val() ;
alert(thisFieldName + ' ' + newFieldName); // shows the stored value and the new one I'm adding
if (thisFieldName == newFieldName) {
alert("Field Name " + newFieldName + " already in use");
$("input[name=newFieldName]").focus() ;
return false;
}
}