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

Need “Yes” and “No” radio button choices to hide or unhide fields but with a small twist.

Explorer ,
Aug 16, 2021 Aug 16, 2021

Copy link to clipboard

Copied

Hello again all!
Trying to finalize a quick fillable form for release to my team but have been stuck on one item for days now!
On my form I have a list of fields that i want hidden by default unless the is a specific choice selected in in the radio button to a question asking whether the next unit to be completed on the form "Is this unit a trailer?"

Anthony5E5C_0-1629166693519.pngAnthony5E5C_1-1629166705699.png

What I want to have happen is when the "No" radio button is selected, I’d like certain fields to display as you can see circled in red in the screenshots above.  The field names are:

 

this.getField("Vehicle2 Vin")
this.getField("Vehicle2Category")
this.getField("Vehicle2year")
this.getField("Vehicle2Make")
this.getField("Vehicle2Model")
this.getField("Vehicle2Drivetrain")
this.getField("Vehicle2TrailerHitchType")
this.getField("Vehicle2Use")
this.getField("Vehicle2GaragingZipCode")
this.getField("Vehicle2CommonDrivingMileRadius")
this.getField("Vehicle2AvgNumberOfTrips")
this.getField("Vehicle2Comprehensive")
this.getField("Vehicle2Collision")
this.getField("Vehicle2PermanentlyAttachedEquip")
this.getField("Vehicle2OptionalNotes")
this.getField("Vehicle2LossPayee")

 

I can get this part to work easily by inputting the following script I pieced together as a custom calculations into the "Vehicle2 Vin" field:

 

if(this.getField("AddAdditionalVehicleorTrailer").value == "No"){

this.getField("Vehicle2 Vin").display = display.visible;

this.getField("Vehicle2Category").display = display.visible;

this.getField("Vehicle2year").display = display.visible;

this.getField("Vehicle2Make").display = display.visible;

this.getField("Vehicle2Model").display = display.visible;

this.getField("Vehicle2Drivetrain").display = display.visible;

this.getField("Vehicle2TrailerHitchType").display = display.visible;

this.getField("Vehicle2Use").display = display.visible;

this.getField("Vehicle2GaragingZipCode").display = display.visible;

this.getField("Vehicle2CommonDrivingMileRadius").display = display.visible;

this.getField("Vehicle2AvgNumberOfTrips").display = display.visible;

this.getField("Vehicle2Comprehensive").display = display.visible;

this.getField("Vehicle2Collision").display = display.visible;

this.getField("Vehicle2PermanentlyAttachedEquip").display = display.visible;

this.getField("Vehicle2OptionalNotes").display = display.visible;

this.getField("Vehicle2LossPayee").display = display.visible;}

else {

this.getField("Vehicle2 Vin").display = display.hidden;

this.getField("Vehicle2Category").display = display.hidden;

this.getField("Vehicle2year").display = display.hidden;

this.getField("Vehicle2Make").display = display.hidden;

this.getField("Vehicle2Model").display = display.hidden;

this.getField("Vehicle2Drivetrain").display = display.hidden;

this.getField("Vehicle2TrailerHitchType").display = display.hidden;

this.getField("Vehicle2Use").display = display.hidden;

this.getField("Vehicle2GaragingZipCode").display = display.hidden;

this.getField("Vehicle2CommonDrivingMileRadius").display = display.hidden;

this.getField("Vehicle2AvgNumberOfTrips").display = display.hidden;

this.getField("Vehicle2Comprehensive").display = display.hidden;

this.getField("Vehicle2Collision").display = display.hidden;

this.getField("Vehicle2PermanentlyAttachedEquip").display = display.hidden;

this.getField("Vehicle2OptionalNotes").display = display.hidden;

this.getField("Vehicle2LossPayee").display = display.hidden;}

 

However, what I want to happen next is if the "Yes" radio button is selected or toggeled to indicate the unit is a "Trailer" and not a vehicle, I want to reveal/display a more limited number of these fields vs when the "No" radio is selected.  

 

Now the kicker is I have a field over a field on the form for two of these fields:  "TrailerMake" and "TrailerModel".  Both the "TrailerMake" and "TrailerModel" fields are sitting on top of the following two current fields on the form respectively, "Vehicle2Make" and "Vehicle2Model" which are listed under the script for the "No" radio button selection.

 

Anthony5E5C_2-1629166737416.png

 

The reason I laid these two fields  "TrailerMake" and "TrailerModel" over those two existing fields “Vehicle2Make" and "Vehicle2Model" is because these and all the other fields are hidden until a radio button selection is made which will bring the correct one of these fields forward when called by the appropriate “Yes” radio button.   Additional logic to do this in the form is because not all the fields are applicable depending if unit is indeed a trailer.  If a person answers "Yes" that the unit is a trailer, then the Make and Model list for Trailers display as unique and separate fields vs the Make and Model type fields for vehicles.

Origninally thinking it would be somewhat easy for me to accomplish this, I just copied the previous script for the “No” radio selection into the custom calculation script of another text field i.e. “TrailerModel”, replacing the radio button value “No” with “Yes”, removing script for some of the other fields that I want to stay hidden because they don’t apply, and inserting two lines for the “TrailerMake” and “TrailerModel” fields to come forward and be visible.

 

Here is the fields i'd like to display if the "Yes" radio is selected:

this.getField("Vehicle2 Vin")
this.getField("Vehicle2Category")
this.getField("Vehicle2year")
this.getField("TrailerMake")
this.getField("TrailerModel")
this.getField("Vehicle2TrailerHitchType")
this.getField("Vehicle2Use")
this.getField("Vehicle2GaragingZipCode")
this.getField("Vehicle2Comprehensive")
this.getField("Vehicle2Collision")
this.getField("Vehicle2PermanentlyAttachedEquip")
this.getField("Vehicle2OptionalNotes")
this.getField("Vehicle2LossPayee")

 

And here is the script I came up with hoping to accomplish:

 

if(this.getField("AddAdditionalVehicleorTrailer").value == "Yes"){

this.getField("Vehicle2 Vin").display = display.visible;

this.getField("Vehicle2Category").display = display.visible;

this.getField("Vehicle2year").display = display.visible;

this.getField("TrailerMake").display = display.visible;

this.getField("TrailerModel").display = display.visible;

this.getField("Vehicle2TrailerHitchType").display = display.visible;

this.getField("Vehicle2Use").display = display.visible;

this.getField("Vehicle2GaragingZipCode").display = display.visible;

this.getField("Vehicle2Comprehensive").display = display.visible;

this.getField("Vehicle2Collision").display = display.visible;

this.getField("Vehicle2PermanentlyAttachedEquip").display = display.visible;

this.getField("Vehicle2OptionalNotes").display = display.visible;

this.getField("Vehicle2LossPayee").display = display.visible;}

else {

this.getField("Vehicle2 Vin").display = display.hidden;

this.getField("Vehicle2Category").display = display.hidden;

this.getField("Vehicle2year").display = display.hidden;

this.getField("TrailerMake").display = display.hidden;

this.getField("TrailerModel").display = display.hidden;

this.getField("Vehicle2TrailerHitchType").display = display.hidden;

this.getField("Vehicle2Use").display = display.hidden;

this.getField("Vehicle2GaragingZipCode").display = display.hidden;

this.getField("Vehicle2Comprehensive").display = display.hidden;

this.getField("Vehicle2Collision").display = display.hidden;

this.getField("Vehicle2PermanentlyAttachedEquip").display = display.hidden;

this.getField("Vehicle2OptionalNotes").display = display.hidden;

this.getField("Vehicle2LossPayee").display = display.hidden;}

 

What happens is the first time when I select “Yes” radio to indicate that the unit is a trailer, it works.  The fields I want to display are showing, and it brings forward the “TrailerMake” and “TrailerModel” fields, while keep hidden the “Vehicle2Make” and “Vehicle2Model” just like i want.

Anthony5E5C_3-1629166770632.png

 

The problem I can’t figure out is when I try to toggle the radio field from “Yes” to “No which would indicate the unit is not a trailer and which simulates if say the person filling out the form made a mistake on the unit type.  However what it seems to do is display only a quarter of the fields that should display when the “No” radio button is selected.  All the question marks are to indicate the missing fields that for some reason won’t unhide.

 

Anthony5E5C_4-1629166793564.png

 

When I toggle back to “Yes” radio button, it works, just not for “No” radio.

 

Anthony5E5C_5-1629166845992.png

Lot there, hope it makes sense.  Please Please please!  Can someone help me solve this riddle with what I’m doing wrong, whether this is impossible, or if anyone has a solution.  Thanks so much!!!!

TOPICS
Create PDFs , General troubleshooting , How to , JavaScript , PDF forms

Views

799

Translate

Translate

Report

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
1 ACCEPTED SOLUTION
Community Expert ,
Aug 16, 2021 Aug 16, 2021

Copy link to clipboard

Copied

The script from "Yes" choice hide fields because you set 'else' on both choices to hide fields, so if choice is "Yes" fields display else fields are hidden.

First use code to hide fields then use conditions to display fields with "Yes" or "No" conditions, something like this:

this.getField("Vehicle2 Vin").display = display.hidden;
this.getField("Vehicle2Category").display = display.hidden;
this.getField("TrailerMake").display = display.hidden;

 

if(this.getField("AddAdditionalVehicleorTrailer").value == "Yes"){
this.getField("Vehicle2 Vin").display = display.visible;
this.getField("Vehicle2Category").display = display.visible;
this.getField("TrailerMake").display = display.visible;}


else if(this.getField("AddAdditionalVehicleorTrailer").value == "No"){
this.getField("Vehicle2 Vin").display = display.visible;
this.getField("Vehicle2Category").display = display.visible;}

View solution in original post

Votes

Translate

Translate

Report

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 ,
Aug 16, 2021 Aug 16, 2021

Copy link to clipboard

Copied

It would be a lot easier to help you if you're able to share this PDF with us.

 

I am also pretty sure that this can be achieved with less scripting.

Votes

Translate

Translate

Report

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
Explorer ,
Aug 17, 2021 Aug 17, 2021

Copy link to clipboard

Copied

Thank you for taking a look @ls_rbls !  I actually got messaged with the help that finally fixed it.  You were absolutely right.  I went from having a bible full of scripts to reducing it to a fraction of whatever that was I thought would work.  lol.  I've barely picked up attempting form creation and javascripting just in the past 30days or so ann everything I'm learning is coming from the various community threads and folks like yourself who are willing to take a look or help.  Thanks again!

Votes

Translate

Translate

Report

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 ,
Aug 18, 2021 Aug 18, 2021

Copy link to clipboard

Copied

LATEST

You're welcome. 

Votes

Translate

Translate

Report

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 ,
Aug 16, 2021 Aug 16, 2021

Copy link to clipboard

Copied

The script from "Yes" choice hide fields because you set 'else' on both choices to hide fields, so if choice is "Yes" fields display else fields are hidden.

First use code to hide fields then use conditions to display fields with "Yes" or "No" conditions, something like this:

this.getField("Vehicle2 Vin").display = display.hidden;
this.getField("Vehicle2Category").display = display.hidden;
this.getField("TrailerMake").display = display.hidden;

 

if(this.getField("AddAdditionalVehicleorTrailer").value == "Yes"){
this.getField("Vehicle2 Vin").display = display.visible;
this.getField("Vehicle2Category").display = display.visible;
this.getField("TrailerMake").display = display.visible;}


else if(this.getField("AddAdditionalVehicleorTrailer").value == "No"){
this.getField("Vehicle2 Vin").display = display.visible;
this.getField("Vehicle2Category").display = display.visible;}

Votes

Translate

Translate

Report

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
Explorer ,
Aug 17, 2021 Aug 17, 2021

Copy link to clipboard

Copied

Yaaas!  Thank You once again Neha!  Totally worked!  Thanks so much for your explaination, total light bulb moment for me know. I know there is several ways to do things and the original way I was trying was based on a co-workers feedback, who like me is self teaching and very very green to creating custom or dynamic forms, and especially javascripting with Adobe, so sort of blind leading the blind.  Right now everything i'm doing or learning is self taught, researching forums and using this communities help which has been amazing!  My plan is to eventually take beginners online course to help me build up the fundementals and become more skilled at this for myself, my team, and hopefully others.  If you or anyone here has any recommendations for any live online courses for beginngers with some proven results, please let me know.  Thanks!

Votes

Translate

Translate

Report

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