I know how to access the current value of a dropdown box. But how can I set it?
I have a dropdown box and one of the choices is 'Other'. When 'Other' is selected, a text box is enabled so the user can describe what they mean by 'Other'. Now, I want to make the dropdown more robust where if after selecting 'Other' and providing a comment the user willingly or not makes a different selection, the user is warned that the 'Other' description will be deleted with a choice to proceed or not. If the user proceeds the description is deleted and the text box disabled; if the user doesn't want to proceed with the deletion the text box is left enabled with its value untouched and the dropdown value is reset to 'Other'. This is the part that I can't figure out: how do I reset the display value of the dropdown?
Thanks for the help!
No, that was my first thought but it didn't work. My understanding is the rawValue property of a dropdown actually refers to the previous selection made and not the current one (displayed value). I have found a fair bit of information on how to access/retrieve the current or previous selection, on how to set the dropdown's selection list, but nothing on how to set the current/displayed value.
Ok, thanks Malcolm. Yes, you were correct about using the rawValue property to reset the selected value of the dropdown.
Why I got so confused is because all my scripting, including trying to reset the newly selected value, was done in the Change event of the dropdown. The rawValue property 'appears' to behave differently here I think because of the order of the events, where it holds the original value through the whole selection process. So essentially, the rawValue during the Change event doesn't hold the newly selected value and will not hold it until the Change event is fully completed.
So I was able to reset the selected value through the Exit event by using a form variable whose value I set in the Change event. So my Change event uses this line at the right location in my script:
cancelDDSelection.value = "yes"; and my Exit event uses the following; if (cancelDDSelection.value == "yes") //if the Change event reset this form variable to 'yes' Not sure if there's a better to do this, but all works as I wanted it to now. Marc
this.rawValue = "Other"; //reset the selected value to 'Other'
cancelDDSelection.value = "no"; //reset the form variable to its default value
cancelDDSelection.value = "yes";
and my Exit event uses the following;
if (cancelDDSelection.value == "yes") //if the Change event reset this form variable to 'yes'
Not sure if there's a better to do this, but all works as I wanted it to now.
Europe, Middle East and Africa