Link to home
Start Free TrialLog in
Avatar of lsctech
lsctech

asked on

JavaScript in Adobe Acrobat

I have a series of check boxes, 5 of them to be specific.  I then have a radio button for member or non member and one more check box for additional service fee.  I then have a total text box.

What I would like to do is have the script calculate the total off of the radio button value they are set to 110 and 130.  then multiply the number of check boxes checked by 50$ and add the additional service fee to the total if checked.  I would like this amount to show up in the Total value text box.

I am not sure how to do the radio buttons. would I do 2 if statements? one for if(this.getField("Naturalist_Membership").value == "110" then ... and one for if (this.getField("Naturalist_Membership").value == "130" then ...?
Avatar of Karl Heinz Kremer
Karl Heinz Kremer
Flag of United States of America image

I would use the following as the calculation script for the result text box:

// Count the checked check boxes
var CB_Count = 0;
var baseName = "CB.";
for (var i=0; i<5; i++)
{
    if (this.getField(baseName + i).value == "Yes")
        CB_Count++;
}

// get the fee
var fee = this.getField("Naturalist_Membership").value;

// store the result in this text box
event.value = (CB_Count * 50) + fee;
Avatar of lsctech
lsctech

ASKER

Here is my exact code. I will also attach my PDF version.  I can not get it to display any text in the textbox. Please help! Thanks.

// Count the checked check boxes
var CB_Count = 0;
var baseName = "yn_";
for (var i=0; i<9; i++)
{
    if (this.getField(baseName + i).value == "Yes")
        CB_Count++;
}

// get the fee
var fee = this.getField("Naturalist_Membership").value;
var extra_fee
if (this.getField("yn_extended").value == "Yes")
  extra_fee = 25;
 
// store the result in this text box
event.value = (CB_Count * 50) + fee + extra_fee;
BHNPsummer-camps-registration-20.pdf
ASKER CERTIFIED SOLUTION
Avatar of Karl Heinz Kremer
Karl Heinz Kremer
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lsctech

ASKER

Ok awesome that works! the only thing is how do I get it not to say 0Off0 in the total text box.  I would be ok with it just saying 0
Ah... I see the same behavior here. Something must have happened when I copied/pasted the code. I am looking into it.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lsctech

ASKER

Thank you for your help!! that did it.