Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Checkbox

sonerndes
Level 2
Level 2

I am very new to creating forms, and need some step by step help with a question.

I am in the process of creating a form and have several instances where I have yes or no questions with checkboxes.  If the user checks no then they need to answer an additional question.  How can I set the form to hide the additional question and only appear if the user selects no?

Thanks

1 Accepted Solution
Niall_O_Donovan
Correct answer by
Level 10
Level 10

Hi Sonya,

For some reason the form didn't come through in one piece (corrupted). I could open it but it did not recognise the format). Anyway I got the intent of the form, so here is another sample, which may be a bit closer to what you want:

https://acrobat.com/#d=ALebgueDXjewHjGyYRdrmw

If you look at the form you will see that I have a static text object for the question and then a radio button group. The group has script in the click event that checks the value of the group (was Yes clicked or No clicked?) and then takes appropriate action - either shows or hides the additional question.

Parallels Desktop1.png

When you select the radio button group you can see in the Object > Binding tab that Yes = 1 and No = 2. Then if you look in the Script Editor there is Javascript to show or hide the subform that contains the additional question.

I have wrapped the additional question objects (text object and radio button object) in the subform because this makes it easier to show and hide (you have to script for one object instead of many objects).

Have a look at this and come back if you need help.

Good luck,

Niall

View solution in original post

0 Replies
Niall_O_Donovan
Level 10
Level 10

Hi,

With Yes/No questions it is better to use radio buttons, which are automatically set up to be mutually exclusive. Also the user will be user to the visual of the round radio button shape and recogonise that they can only provide one answer.

You will need to do a little scripting for the radio button group, basically setting the presence of the optional questions from visible to hidden. If you have LC Designer ES2 there is a handy tool called Action Builder that can help you build the script.

Here is an example:

https://acrobat.com/#d=MnqBQrsWVc5gKwQFC9TyZA

https://acrobat.com/#d=FXLq025O2C0aDMh9YqpH1g

Hope that helps,

Niall

Steve_L_Walker
Level 10
Level 10

Here is a simple sample that uses radio buttons made to appear as check boxes.

Untitled.png

Steve

sonerndes
Level 2
Level 2

Hi,

I have attached a sample of what I am doing, could you please look at this and give me some advice on how to hide the second part of the questions.

Thanks

Sonya Patton

Steve_L_Walker
Level 10
Level 10

Sonya,

Non-employees cannot use the attachment feature. It was abused by hackers and became a security problem. Please forward your form via email to stwalker.adobe@gmail.com.

Steve

sonerndes
Level 2
Level 2

Thanks for your answer.  I do not have LiveCycle ES, I only have LiveCyle 8.0.  The concepts you sent me were great, but I don't have enough scripting knowledge to make them work on my form.  Would there be someone that could look at my form and could help me with the scripting?

Thanks

Sonya

Niall_O_Donovan
Level 10
Level 10

Hi Sonya,

If you upload your form (or the part giving trouble) onto http://www.acrobat.com and then post the link here.

I am sure there will be plenty of help at hand.

Niall

Niall_O_Donovan
Correct answer by
Level 10
Level 10

Hi Sonya,

For some reason the form didn't come through in one piece (corrupted). I could open it but it did not recognise the format). Anyway I got the intent of the form, so here is another sample, which may be a bit closer to what you want:

https://acrobat.com/#d=ALebgueDXjewHjGyYRdrmw

If you look at the form you will see that I have a static text object for the question and then a radio button group. The group has script in the click event that checks the value of the group (was Yes clicked or No clicked?) and then takes appropriate action - either shows or hides the additional question.

Parallels Desktop1.png

When you select the radio button group you can see in the Object > Binding tab that Yes = 1 and No = 2. Then if you look in the Script Editor there is Javascript to show or hide the subform that contains the additional question.

I have wrapped the additional question objects (text object and radio button object) in the subform because this makes it easier to show and hide (you have to script for one object instead of many objects).

Have a look at this and come back if you need help.

Good luck,

Niall

sonerndes
Level 2
Level 2

That worked great!  Thank you so much for your help.

One of other question if you can help me with.

I have a numeric field where the number has to be 25,000 or more.  How can I script that field not to take anything less and give a message to the user if they try to enter a lesser number?

Thanks again for your help.

Sonya

Niall_O_Donovan
Level 10
Level 10

Hi Sonya,

Something like this in the exit event of the numeric field (i'd recommend a numeric field because then when you are testing you are dealing with just numbers):

if (this.rawValue < "25000")

{

     this.rawValue = "25000";

     xfa.host.messageBox("The minimum value for this field is 25,000. \n\nI have reset the field to this minimum value for you. \n\nThank you!", "Minimum value", 0, 0);

}

When you select the field you can give is a display pattern from the Object > Field tab:

num{z,zzz,zzz,zz9}

You can extend this by wrapping additional text strings in single quotes.

num{z,zzz,zzz,zz9' booklets'}

The help file will have more information on the messageBox and patterns.

I hope that works,

Niall

sonerndes
Level 2
Level 2

Niall,

This message box worked great.

Not everyone filling in the form will answer that question, how can they tab over that field without getting the error message saying field must be 25,000 or more.

Sonya

Niall_O_Donovan
Level 10
Level 10

Hi Sonya,

We just need to get a another check in the if statement to look at a null condition:

if (this.rawValue !== null && this.rawValue < "25000")
{
     this.rawValue = "25000";
     xfa.host.messageBox("The minimum value for this field is 25,000. \n\nI have reset the field to this minimum value for you. \n\nThank you!", "Minimum value", 0, 0);
}

Basically if the field is null, then the error message will not appear. It will only appear if the field has a value AND that value is less than 25000.

I hope that helps,

Niall

sonerndes
Level 2
Level 2

Niall,

You have been an excellent help to me.

I need help with one more scipt, I hope you do not mind.

I have attached a link with the section I need help with.

I need the inventory total to divide by the annual goal mutiply x 12 = how many month's supply is this

so inventory      x 12 = month's supply.

    annual goal       

Hope that made sense.

Thank you again for all your help.

Sonya

https://acrobat.com/#d=v3tWWEFoCuVupyGzBDf3TQ

Niall_O_Donovan
Level 10
Level 10

Hi Sonya,

Here is the form back to you: https://acrobat.com/#d=hpDKA749lBmHiQGdSS6b3Q

I have sorted the calculations in the total fields. Because your pages and subforms were not named it complicated the referencing of objects in the scripts. Hopefully you can following the changes.

I have put the calculation in the supply field inside an if statement that checks that the annual goal is not zero or null.

Hope that helps,

Niall