I have a form in the Classic Designer that uses Javascript to populate a dropdown with a number of credits for the student to select from. The values in the dropdown are based on 2 hidden text fields called MIN_UNITS and MAX_UNITS (which are filled via a lookup).
The Classic Javascript:
const minUnits = parseInt($('.min-units input').val()); const maxUnits = parseInt($('.max-units input').val()); const startUnits = parseInt($('.start-units input').val()); newCourseUnits.empty(); for (let x = minUnits; x <= maxUnits; x++) { console.log('Value: ' + x); newCourseUnits.append($('<option></option>').val(x).html(x)) }
The hidden fields:
The dropdown looks like this:
I'm trying to replicate this functionality in the New Designer using LFForm, but I'm not having any luck.
My LFForm code is (Field 423 is MIN_UNITS and 422 is MAX_UNITS):
* "choice " is just in there for testing - I've tried removing it and just displaying x for the label and get a blank entry
for (let x = LFForm.getFieldValues({fieldId: 423}); x <= LFForm.getFieldValues({fieldId: 422}); x++) { LFForm.changeFieldOptions({fieldId: 438}, [{label: "Choice " + x}], "add") }
I've also tried using variable assignments:
var minUnits = LFForm.getFieldValues({fieldId: 423}); var maxUnits = LFForm.getFieldValues({fieldId: 422}); for (let x = minUnits; x <= maxUnits; x++) { LFForm.changeFieldOptions({fieldId: 438}, [{label: "Choice " + x}], "add") }
But I only get one option with "Choice ":
Any assistance would be greatly appreciated.