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

Form Checkboxes

ple
Registered: Aug 25 2011
Posts: 3
Answered

Hello,
 
I am trying to create a form in Acrobat Pro using checkboxes. I would like to allow users to select only one option. I also have each checkbox scripted to show and hide a button when the option is selected. Any suggestions on how to allow users to select only one option would be helpful!
 
Thank You!

My Product Information:
Acrobat Pro 10.1, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Accepted Answer
Give them the same name but different export values.

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

ple
Registered: Aug 25 2011
Posts: 3
@try67

I tried your suggestion but it still did not work. I should have mentioned that each of my check boxes have a different script. I am not sure if that makes a difference...

Here is the sample script I have for the mouse up event:

checkbox1
var nHide = event.target.isBoxChecked(0)?display.visible:display.hidden;
this.getField("SUBMIT").display = nHide;
this.getField("txtSuperEmail").display = nHide;
this.getField("SuperName").display = nHide;

checkbox2
var nHide = event.target.isBoxChecked(0)?display.visible:display.hidden;
this.getField("Submit to Approver").display = nHide;
this.getField("APPROVE").display = nHide;
this.getField("ApproverName").display = nHide;
this.getField("txtEmail").display = nHide;
this.getField("txtManagerApprove").display = nHide;

KellyMcC
Acrobat 9ExpertTeam
Registered: Jul 11 2011
Posts: 389
ple,

Your checkboxes still have different names. The only way to make sure that only one is selected is to have each named "checkbox", not "checkbox1" & "checkbox2". The script shouldn't make a difference, since you aren't referencing the field name, just the checkbox status.

Kelly McCathran
Adobe Community Expert
Certified Technical Trainer+

ple
Registered: Aug 25 2011
Posts: 3
KellyMcC,

Sorry I should have been more clear. When I change the name of the check boxes to have the same name my javascript to show or hide a layer does not work. If the user selects an option and later changes their mind and chooese another option my javascript for the check box selected does not run. It looks like it is commiting to the first selection only. Is there a way I can change that?


gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
You need to name the check boxes with the same name and different export values. You then need to use same script for the check boxes 'mouse up' action. Your script should check the value of the check box group and execute the code based on the export value. You should also provide for the 'unchecked' state.

Assuming you use export values of "1" and "2" for your 2 buttons:

switch(event.value) {
case "1":
this.getField("SUBMIT").display = display.visible;
this.getField("txtSuperEmail").display = display.visible;
this.getField("SuperName").display = display.visible;
break;

case "2":
this.getField("Submit to Approver").display = display.visible;
this.getField("APPROVE").display = display.visible;
this.getField("ApproverName").display = display.visible;
this.getField("txtEmail").display = display.visible;
this.getField("txtManagerApprove").display = display.visible;
break;

default:
// all other values hide all fields
this.getField("SUBMIT").display = display.hidden;
this.getField("txtSuperEmail").display = display.hidden;
this.getField("SuperName").display = display.hidden;
this.getField("Submit to Approver").display = display.hidden;
this.getField("APPROVE").display = display.hidden;
this.getField("ApproverName").display = display.hidden;
this.getField("txtEmail").display = display.hidden;
this.getField("txtManagerApprove").display = display.hidden;
break;
}

George Kaiser