Skip to main content
Participant
July 31, 2020
Question

Calculate PDF checkboxes

  • July 31, 2020
  • 1 reply
  • 752 views

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();

 

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
July 31, 2020

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) 

Participant
July 31, 2020

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.

try67
Community Expert
Community Expert
July 31, 2020

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.