Background: I need to transfer a person's first and last name values from one set of fields to a set of hidden fields, which are used for a database lookup. Depending on a dropdown choice, the names are pulled from the corresponding fields into these hidden fields. Since Lookup Rules don't have this sort of logic built-in, I've determined this may be the best way to handle it.
I'm copying the values using the jQuery val() function. This works fine, until I try to run a database lookup on the hidden fields. The lookup fails to find any results. If I choose the original text field from where the text originates, the lookup runs just fine.
See the code below which copies the original values into the hidden field's input then runs the database autofill function. The text is copied just fine, and the lookup runs fine if the other text fields are chosen as the lookup rules.
Why is the lookup rule successful if I run it on the original fields, but not on the fields where the values were copied?
var relationSelected = $('.relation').find(":selected").text(); //get the relation type //determine if the employee is claiming on their own behalf, or a spouse/dependent if(relationSelected == 'Employee') { $('.lookupFirstName input').val($('.employeeFirstName input').val()); $('.lookupLastName input').val($('.employeeLastName input').val()); } else { $('.lookupFirstName input').val($('.claimantFirstName input').val()); $('.lookupLastName input').val($('.claimantLastName input').val()); } //run the DB lookup autofill();