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("Naturali st_Members hip").valu e == "110" then ... and one for if (this.getField("Naturalist _Membershi p").value == "130" then ...?
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("Naturali
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_extende d").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
// 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_
var extra_fee
if (this.getField("yn_extende
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you for your help!! that did it.
// 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_
// store the result in this text box
event.value = (CB_Count * 50) + fee;