These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Select option "yes" for check box, a text field below this automatically states "mandatory", how to do this?

Abbica
Registered: Feb 4 2009
Posts: 38
Answered

Hi, I have a check box, with an option of either 'Yes' or 'No'. What we want to achieve is, if you check the box 'Yes', the text field below it will automatically then state, 'Mandatory'. But if you select 'No', nothing will appear as it won't be mandatory then.
 
Does anyone know if I can do this and if so, how do I go about doing this please?

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Place this as the custom calculation code of your text box:

event.value = getField("CheckBox1").value=="Yes" ? "Mandatory" : "";

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

Abbica
Registered: Feb 4 2009
Posts: 38
Hi there, thanks for the quick response. I opened the properties for my text field and placed your script into the custom format Script and nothing happened. Would I not have to put the code into the check box so when that is clicked, the text field auto states'mandatory'. Can you even place script into a check box? Can't seem to see a place but maybe I am totaly away with the fairies on this??
try67
Expert
Registered: Oct 30 2008
Posts: 2398
You need to adjust the name of the field in the code to match the name of your check box. Remember it's case-sensitive.
It's possible to add code to a check-box's MouseUp action, but it's not necessary for this.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

Abbica
Registered: Feb 4 2009
Posts: 38
It is still not working for me. I will show you the name of my check box and what I have in on my script for the text field.

In the properties field for my Check Box, Export Value 'Yes' General Name is 'PremiumAddit premium'

Then I go to my text field below it and it is called 'Premium Exist pol number'. The Format>Custom Format Script: event.value = getField("PremiumAddit premium").value=="Yes" ? "Mandatory" : "";So, when I go to test it and check the box, 'Yes', mandatory does not automatically autofil this box.

Sorry for being a pain but your help is much appreciated.
try67
Expert
Registered: Oct 30 2008
Posts: 2398
This is not a Format script, it's a Calculate script.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

Abbica
Registered: Feb 4 2009
Posts: 38
Oh, you genius, sorry didn't realise. I haven't a clue where to put script between custom, validate and calculate, I am at a loss. Thanks so much for your help though, great help.
Abbica
Registered: Feb 4 2009
Posts: 38
Ok, slight problem, when I select the check box 'Yes', the 'Mandatory' comes up which is great, but then, when I go to type over this 'Mandatory' field, it allows me to but then the 'Mandatory' just reappears again?? it just keeps popping back up, I need it to disappear and be able to type on top of this. Is this possible I say cringing!
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Oh, you should have mentioned that earlier...
Actually, the solution is to move the script to the MouseUp action of your check-box, and use this code:

getField("Premium Exist pol number").value = getField("PremiumAddit premium").value=="Yes" ? "Mandatory" : "";

Make sure to remove the calculation script from the text field...

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

Abbica
Registered: Feb 4 2009
Posts: 38
Sorry for sending you on a wild goose chase, never thought but oh to have your knowledge. Thanks very much, that worked for me, at least it's great I know both ways of doing it now, wasn't so great for you tho, sorry. :)
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Accepted Answer
Don't worry about it... And you can mark the thread as answered, if you want.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com