Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Resetting a form when selecting a different option using Java

New Here ,
Mar 25, 2025 Mar 25, 2025

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.

TOPICS
How to
170
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 25, 2025 Mar 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">
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 25, 2025 Mar 25, 2025

Where did you place the code?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 25, 2025 Mar 25, 2025

PS. This is JavaScript, not Java...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 25, 2025 Mar 25, 2025

Currently, i have that code in my first radio button selection. Once the "001" option is selected i have another option that needs to be chosen and then populate the rest of the fields. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 26, 2025 Mar 26, 2025

Move the code to the calculation event of any text field (it can even be hidden).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 26, 2025 Mar 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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 26, 2025 Mar 26, 2025
LATEST

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. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines