I am working in the new Forms 11 Form designer trying to employ the LFForm object syntax for something I used to be able to with older code in the Classic Form Designer, and I am stumped! I am trying to set a single line field to the text of a choice (a city name) in a dropdown menu (not the associated assigned value, which is a permit number).
The following code works to set the value of Field 22 to the assigned value of Field 2 [the permit number], but not the TEXT of the choice [the city name] of Field 2. I want to set it to the city name.
LFForm.onFieldChange(function(){ LFForm.setFieldValues({fieldId: 22}, LFForm.getFieldValues({fieldId: 2})) }, {fieldId: 2})
This is the code that I would have used in the Classic designer interface to accomplish this:
$(document).ready(function () {
$('#q2').on("change", function(){
var citytext = $('#q2 option:selected').text();
$('#q22 input').val(citytext).change();
});
});
Can anyone help me revise my code to specify the Field2 choice text, rather than its assigned value? Thank you!