Let me preface that I have very little knowledge of what I'm doing, I've mostly googled to get this far.
I have an OptionSet (Yes/No) field on my form.
I've set a OnChange Event for the field it to trigger a Javascript function.
The Javascript function checks if the value of the field is Yes, and if so it makes a WebResource visible.
It "sort of" works, but it requires me to toggle away from Yes before the WebResource is shown.
I.E. If the field is defaulted to [ -- Select -- and I choose [ Yes , nothing happens. But as soon as I toggle from [ Yes to any other value (No or back to default --Select--), then the function triggers and the WebResource is shown. So apparently OnChange is seeing the previous value when I change the field??? I can't seem to make head-or-tails of what actually causes the OnChange to trigger.
Below is a sample of my code:
function SetInvisibleWebResource(executionContext) { var formContext = executionContext.getFormContext(); var Q1 = formContext.getAttribute("crc7b_segment1").getValue(); if (Q1 !== null){ if (Q1 == 260830000){ formContext.getControl("WebResource_Segmentation_1").setVisible(true); }} }
260830000 is the value of Yes
Can anyone help point out what I'm doing wrong?