Problem with javascript code in form
Hello, I hope you are well. I need help with this code for a form with two conditional dropdown lists.
I have two dropdown lists. One is a series and you can choose from 1 to 5 and each of these has values from 1 to 19 (some more, some less) so, when choosing a series, the following drop-down list should show what each one contains. So far it works for me and this is the code:
// Arrangement with the Series lists and the UTs of each one
var series = {
"1": ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19"],
"2": ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15"],
"3": ["1", "2", "3", "4", "5", "6"],
"4": ["1", "2", "3", "4", "5", "6"],
"5": ["1", "2", "3", "4", "5", "6", "7", "8"]
};
// Function to update the UT field based on the selected series
function actualizarUT() {
var serieSeleccionada = this.getField("Serie").value;
var utDropdown = this.getField("UT");
utDropdown.setItems(series[serieSeleccionada]); // Set the UTs according to the series
}
// Assign event to series field to dynamically update UT values
this.getField("Serie").setAction("Keystroke", actualizarUT());
This is what it would look like on the form:


Now the problem is that, when selecting a number from the UT list, it is not selected, but rather the first number in the list is always placed. What can I do to keep the number on the list I want selected? I hope you can help me and I hope I have explained myself well. Thank you very much in advance!

