Hi there - I currently have a form that populates a text field (field_lx21m) with a value based on 3 other fields that a user can fill out. I am trying to use the value of the text field to then populate a lookup field (field_f3s8k) from the code in the help docs.
The code I am using is below. The text field looks like it populates correctly. However, the value does not seem to be copying to the lookup field at all. Any help would be much appreciated!
jQuery(document).ready(function($) {
var field_i12n_value = $('#field_i12n').val();
var field_aw49p_value = $('#field_aw49p').val();
var field_iqa64_value = $('#field_iqa64').val();
// Checking conditions and copying values
if (field_i12n_value !== '') {
$('#field_lx21m').val(field_i12n_value);
} else if (field_aw49p_value !== '') {
$('#field_lx21m').val(field_aw49p_value);
} else if (field_iqa64_value !== '') {
$('#field_lx21m').val(field_iqa64_value);
} else {
// If none of the conditions are met, keep field_f3s8k empty or handle as needed
$('#field_lx21m').val(field_iqa64_value);
}
// Trigger custom event after the conditionals
$('#field_lx21m').change(function(){
var sourceField = $('#field_lx21m').val();
$('#field_f3s8k').val(sourceField);
$('#field_f3s8k').trigger({ type:'change', originalEvent:'custom' });
});
});
Please login or Register to submit your answer