Skip to main content
Participating Frequently
March 25, 2025
Question

Resetting a form when selecting a different option using Java

  • March 25, 2025
  • 3 replies
  • 374 views

Hello,

 

I am currently creating a form where i am using a script that will populate more fields or selection depending on the option. However, i am running into the issue where i make a selection and then the other options stay visible.

 

Current script i am using "xx" and "xxx" are place holders. 

var selectedValue = this.getField("Selection").value;

// Perform actions based on the selected value
if (selectedValue === "01") {
this.getField("02").display = display.visible;
this.getField("03").display = display.visible;
this.getField("04").display = display.visible;
this.getField("05").display = display.visible;
this.getField("002").display = display.hidden;
this.getField("003").display = display.hidden;
this.getField("004").display = display.hidden;
} else if (selectedValue === "001") {
this.getField("01").display = display.hidden;
this.getField("02").display = display.hidden;
this.getField("03").display = display.hidden;
this.getField("04").display = display.hidden;
this.getField("002").display = display.visible;
this.getField("003").display = display.visible;
this.getField("004").display = display.visible;
} else {

So you can see when i make a selection some fields will become visible and other will become hidden. I need to be able to make them hidden or reset again once i change selections. Thank you in advance.

3 replies

Participant
March 26, 2025

It looks like the issue is that previous selections are leaving some fields visible when switching. To fix this, you should first hide all fields before making the relevant ones visible based on the new selection. This way, every time you change the selection, only the correct fields will be shown while others remain hidden. Hope this helps!

josh_2389Author
Participating Frequently
March 26, 2025

Hello,

 

I believe i have done this on a "property level" setting all the fields as hidden until the selection is made. The script just shows the events that follows that selection. So far i have added another script the secondary radio options and seems to be working as of now. Thank you for the response. 

try67
Community Expert
Community Expert
March 25, 2025

Where did you place the code?

try67
Community Expert
Community Expert
March 25, 2025

PS. This is JavaScript, not Java...

kglad
Community Expert
Community Expert
March 25, 2025

in the future, to find the best place to post your message, use the list here, https://community.adobe.com/

p.s. i don't think the adobe website, and forums in particular, are easy to navigate, so don't spend a lot of time searching that forum list. do your best and we'll move the post (like this one has already been moved) if it helps you get responses.



<"moved from using the community">