• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to calculate multiple check boxes with a dropdown

New Here ,
May 26, 2021 May 26, 2021

Copy link to clipboard

Copied

Could I please have help to solve a unique ordering form that I'm creating.

 

Atm, I have 8 product images in check boxes and a single dropdown with quantity breaks (10, 25, 100, 250).

PLEASE NOTE: The 8 products each have 4 lots of price quantity breaks. Yeah, that's a lot of prices!

 

How do I get my Order total field to caluclate this and ADD the showbag? See attachment, if it helps.

TOPICS
How to , JavaScript , PDF forms

Views

718

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 27, 2021 May 27, 2021

Copy link to clipboard

Copied

Hi,

 

So my understanding is that you would have a user select a number of pieces (up to 8), and a drop down that allows you to select a number of items (which applie to all selected), but each of the 8 items has a different price point. in which case something like this would probably work.

 

Placed in the validate of the drop down field, and have the property of the drop down set to "commit value immediately".

 

 

// these could be set to anything
var item1Price = [ "10", "20", "30", "40"];
var item2Price = [ "10", "20", "30", "40"];
var item3Price = [ "10", "20", "30", "40"];
var item4Price = [ "10", "20", "30", "40"];
var item5Price = [ "10", "20", "30", "40"];
var item6Price = [ "10", "20", "30", "40"];
var item7Price = [ "10", "20", "30", "40"];
var item8Price = [ "10", "20", "30", "40"];

var dropdownListValue = event.value;
var placeInList = 0;
switch ( dropdownListValue){
    case "25":
        placeInList = 1;
        break;
    case "50":
        placeInList = 2;
        break;
    case "75":
        placeInList = 3;
        break;
    default:
        placeInlist = 0;
        break;
}
var runningTotal = 0;
if (this.getField("item1Check").isBoxChecked(0)){
    runningTotal = runningTotal + (dropdownListValue * item1Price[placeInList]);
}
if (this.getField("item2Check").isBoxChecked(0)){
    runningTotal = runningTotal + (dropdownListValue * item2Price[placeInList]);
}
if (this.getField("item3Check").isBoxChecked(0)){
    runningTotal = runningTotal + (dropdownListValue * item3Price[placeInList]);
}
if (this.getField("item4Check").isBoxChecked(0)){
    runningTotal = runningTotal + (dropdownListValue * item4Price[placeInList]);
}
if (this.getField("item5Check").isBoxChecked(0)){
    runningTotal = runningTotal + (dropdownListValue * item5Price[placeInList]);
}
if (this.getField("item6Check").isBoxChecked(0)){
    runningTotal = runningTotal + (dropdownListValue * item6Price[placeInList]);
}
if (this.getField("item7Check").isBoxChecked(0)){
    runningTotal = runningTotal + (dropdownListValue * item7Price[placeInList]);
}
if (this.getField("item8Check").isBoxChecked(0)){
    runningTotal = runningTotal + (dropdownListValue * item8Price[placeInList]);
}
this.getField("Order").value = runningTotal;



 

 

This is programmed from the hip ( on my iphone) so may have an issue but it should be a good starting point.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 27, 2021 May 27, 2021

Copy link to clipboard

Copied

Hi BarlaeDC, 

 

85% correct. I need the showbag's price to be included in the order price too. The showbag is complusory for the order hence it has no check box. Is that possible?

 

I also inserted your script to the dropdown's validate field and selected 'Commit selected value immeditately' but no pricing appears in testing phase. Is it safe to assume I no longer need the Order total field or should the price populate inside it?

 

I look forward to your responds, appreciate you looking at this for me.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 28, 2021 May 28, 2021

Copy link to clipboard

Copied

Hi,

 

Just add the showbag to this line;

 

this.getField("Order").value = runningTotal + showbagCost;

 

Have you checked that all the fields are correctly named as per your form?

Does the console give you any errors?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 03, 2021 Jun 03, 2021

Copy link to clipboard

Copied

LATEST

Hi BarlaeDC,

Yes I did and there's no errors either. I've managed to track down a friend's friend to help me debug this.

Many thanks for the inital code as it's a great foundation to work from.

Votes

Translate

Translate

Report

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