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

If radio button is selected then text field shows up

Community Beginner ,
Nov 01, 2023 Nov 01, 2023

hello,

I'm brand new to JavaScript and Adobe form fields,
I create a form with five radio buttons "Option 1, "Individual," "Option 2, "Couple," "Option 3, "Single parent" "Option 4, "Family" "Option 5, "Waives" and a text field" (please specify)".
I want the form to show a text field (please specify)", (and become required if possible) if someone selects the radio button option 5 "Waives", but I don't want it to appear as an option if he chose “Option 1,2,3,4,”.

What is the best way to do this?

Thanks in advance

 

1.5K
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 ,
Nov 01, 2023 Nov 01, 2023

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 ,
Nov 01, 2023 Nov 01, 2023

Let's say radio buttons are named "Group1", (change to your actual name) use this as custom calculation script of text field:

event.target.display = this.getField("Group1").valueAsString === "Waives" ? 0 : 1;
event.target.required = this.getField("Group1").valueAsString === "Waives" ? true : false;

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 Beginner ,
Nov 14, 2023 Nov 14, 2023

thks for your answwer, it not working 😞  let try another trategy,

I have create a form with one check box buttons and one text field..

the checkbox field named "checkBox" and a text field named "textField" , I want to be abble to show the text field when the checkbox is checked and hide it when it's unchecked.

 

thansk in advance

 

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 ,
Nov 14, 2023 Nov 14, 2023

As Mouse Up action of checkbox:

this.getField("textField").display = event.target.value == "Off" ? display.hidden : display.visible;

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 Beginner ,
Nov 15, 2023 Nov 15, 2023

hi, thks it work:) I did the same thing with certain radio buttons. If I accidentally check it and want to clear the form, the checkbox won't become hidden again. Can you assist me with it? 

 

thanks in advance

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 ,
Nov 15, 2023 Nov 15, 2023

For radio button it won't work like that because you can't uncheck radio button.

You need to use calculation script in text field or hide checkbox with a same button you reset radio buttons.

Check my first post above for calculation script.

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 Beginner ,
Nov 15, 2023 Nov 15, 2023

Thanks  it work well!!  

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 Beginner ,
Nov 22, 2023 Nov 22, 2023
LATEST

late say, when selecting a radio button I have to make a series of text fields disappear and display a message behind them. is this possible, if so do you have a formula for me, thank you

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 ,
Nov 22, 2023 Nov 22, 2023

This one liner will not work.

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