## Calculate PDF checkboxes

New Here ,
Jul 31, 2020

Copy link to clipboard

Copied

Hey guys

I'm new here and I'm a complete novice at Javascript. I'm a designer that wants to get better at coding.

I'm trying to add a numeric value to the checkboxes in the 'size' row. Each of the 6 checkboxes will have a different value. Those values will be added together and multiplied by the values that will be inserted in the 'quantity' and 'colours' rows, to get a total. So the total at the end should be something like size(s)*quantity*colours.

I'm currently stuck at applying values to the checkboxes. I've been at it for about 2 weeks now (seriously) and haven't figure it out. I used arrays to group the checkboxes as seen in the code below. I can check which box is ticked, but I don't know how to apply values to the boxes and only calculate boxes that are ticked.

Any help would be greatly appreciated.

Thanks

var estimate = this.getField("estimate");
var sizesMale = ["male_small","male_medium","male_large","male_xl","male_2xl","male_3xl"];
var quantityMale = new Array("MQ1","MQ2","MQ3","MQ4","MQ5","MQ6");

function maleShirtPrice(){

var maleShirtPrices = 0;

for (var i = 0; i < sizesMale.length; i++)

{
sizesMale[i].exportValues = [100,200,300,400,500,600];
sz = this.getField(sizesMale[i]).exportValues;
};

console.println(sz);

if(sz.value = true)

{
maleShirtPrices = ;

};

return maleShirtPrices;

maleShirtPrices()
}

estimate.value = maleShirtPrice();

TOPICS
Acrobat SDK and JavaScript, How to, PDF forms

Views

47

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

## Calculate PDF checkboxes

New Here ,
Jul 31, 2020

Copy link to clipboard

Copied

Hey guys

I'm new here and I'm a complete novice at Javascript. I'm a designer that wants to get better at coding.

I'm trying to add a numeric value to the checkboxes in the 'size' row. Each of the 6 checkboxes will have a different value. Those values will be added together and multiplied by the values that will be inserted in the 'quantity' and 'colours' rows, to get a total. So the total at the end should be something like size(s)*quantity*colours.

I'm currently stuck at applying values to the checkboxes. I've been at it for about 2 weeks now (seriously) and haven't figure it out. I used arrays to group the checkboxes as seen in the code below. I can check which box is ticked, but I don't know how to apply values to the boxes and only calculate boxes that are ticked.

Any help would be greatly appreciated.

Thanks

var estimate = this.getField("estimate");
var sizesMale = ["male_small","male_medium","male_large","male_xl","male_2xl","male_3xl"];
var quantityMale = new Array("MQ1","MQ2","MQ3","MQ4","MQ5","MQ6");

function maleShirtPrice(){

var maleShirtPrices = 0;

for (var i = 0; i < sizesMale.length; i++)

{
sizesMale[i].exportValues = [100,200,300,400,500,600];
sz = this.getField(sizesMale[i]).exportValues;
};

console.println(sz);

if(sz.value = true)

{
maleShirtPrices = ;

};

return maleShirtPrices;

maleShirtPrices()
}

estimate.value = maleShirtPrice();

TOPICS
Acrobat SDK and JavaScript, How to, PDF forms

Views

48

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 31, 2020 0
4 Replies 4
Most Valuable Participant ,
Jul 31, 2020

Copy link to clipboard

Copied

Are the Quantity and Colours fields text fields with just numbers? Do you basically want to sum all the products of the columns where the check-boxes are ticked? So in the case above the result would be:

(QuantitySmall * ColoursSmall_1 * ColoursSmall_2 * ColoursSmall_3)  + (Quantity3XL* Colours3XL_1 * Colours3XL_2 * Colours3XL_3)

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 31, 2020 0
New Here ,
Jul 31, 2020

Copy link to clipboard

Copied

Thanks for the reply. Yes the quantity and colours filed will be numbers only. Yes I'd want the columns sumed in the way you just put it. Never thought of calculating it that way, actually.

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 31, 2020 0
Most Valuable Participant ,
Jul 31, 2020

Copy link to clipboard

Copied

So you think you can tackle it now, or do you still need help with it? If you still need help, please post the names of all of the fields involved.

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 31, 2020 0
LATEST
New Here ,
Jul 31, 2020

Copy link to clipboard

Copied

I'll try it in a few when I get home. I'm imagining that I'll have to get rid of the arrays and write values for each individual checkbox, quantity and colour fields. I'd have to add values with the arrays anyway, but I went that route because I thought there'd be less typing and shortcuts made available with the arrays. However, I'm a noob. I'll give this a try though.

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 31, 2020 0