Dropdown makes unreasonable demands before saving!

I have a form with input fields and a submit button. It allows users to enroll in courses, so one of the input fields is a dropdown listing all the courses.

Each course has an item page showing the course description and all the details. If the user wants to enroll in a course, they click an ENROLL button on the item page that opens the enrollment form. So I put the name of the course that they’re viewing into the value property of the dropdown:

$w(‘#dropCourse’).value = session.getItem(“Course”)

All this seems to work fine. When the form loads, there’s the correct course selected in the dropdown seemingly ready to go. When the submit button is clicked, I get a success message, and the fields get saved properly–all but the value I put into the course dropdown!

The only way to get it to save is if the user interacts with it! If I select another course from the dropdown, then it saves. If I select the original course again, it also saves. But without interaction–nope. nada. zilch. BTW, the dropdown is a required field, so it seems to know there’s a value in there.

Thanks for your help

Hi Peter,

I too was surprised to see that behavior when assigning values to elements in code. The solution is to use a setFieldValue function call.

Thanks, Anthony! That worked.

Seems bizarre and clunky, but… whatever, right? Much appreciated