I need to update the value of some input fields of a form, using values from a second (dynamically generated) div.
Here’s the code
$("#second_update_form_data :input").each(function(index) {
//find all input fields in the second div
var FieldName = $(this).attr("name");
var FieldValue = $(this).val();
//try to get the corresponding field from the original form to change it
var Selector = "#TT_CartForm__form input[name=" + FieldName + "]";
var OriginalFiled = $(Selector);
This does not work, but I’m not sure why. I could add an id to the original input fields and use that to select them, but I’d prefer to understand what’s wrong and use the correct selector.
Thanks in advance,
kind regards
EDIT:
I’m sorry, I realize I didn’t specified which part doesn’t work.
It is the last line, when I try to select using Selector, so it’s this last one that seems to be wrong
Try changing your quotations around to ensure string vaiable read. something else to keep in mind, IE7 and IE8 support attribute selectors only if a !DOCTYPE is specified. and in IE6- they dont work ata all
Also double check your element ID name, I notice it has two areas that are underscore and one area has 2 underscores. Make sure the div holding your input has that exact same id value