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

check box value dependent on the combo box selection

Explorer ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

I have 3 check boxes that need to have a different export value (to calculate price) depending on what option is selected in a drop down menu.

 

The 3 check boxes are: "paint check" "engine check" and "ceramic check"

 

if in the drop down menu ("package type") "Exterior" is selected I need "paint check" = 150, "engine check" = 35 and "ceramic check" = 200 ONLY if those boxes are checked.

 

if in the drop down menu ("package type") "Exterior 2" is selected I need "paint check" = 180, "engine check" = 45 and "ceramic check" = 400 ONLY if those boxes are checked.

 

etc.

 

I have figured out the javascript to assign the value but I cant figure out how to make it say this is the value if the box is checked 

 

I had code in the custom validation script in the drop down menu options. 

 

if (event.value =="Exterior") 

{this.getField ("paint check").value = "150";

}

 

and this assigns the value which is great, but it does so without the check box being checked. I need the value to ONLY apply if Exterior is selected AND "paint check" is checked. 

 

I just cant seem to figure out how to write the code for it to say that. 

TOPICS
Create PDFs , General troubleshooting , How to , JavaScript , PDF forms

Views

947

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

correct answers 1 Correct answer

Community Expert , Feb 23, 2021 Feb 23, 2021

Try using code in "custom calculation script" of dropdown field "package type":

var v1 = 0;
var v2 = 0;
var v3 = 0;
if(event.value == "Exterior" && this.getField("paint check").valueAsString != "Off")
v1 = 150;
if(event.value == "Exterior" && this.getField("engine check").valueAsString != "Off")
v2 = 35;
if(event.value == "Exterior" && this.getField("ceramic check").valueAsString != "Off")
v3 = 200;
if(event.value == "Full Package" && this.getField("paint check").valueAsString != "Off")
v1 = 180;
if(event.v

...

Votes

Translate

Translate
Enthusiast ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

You can't do it like that.

In what field are you showing value 150...etc?

 

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
Explorer ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

the "150" value will be shown in the "addon total" box 

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
Enthusiast ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

In your other post https://community.adobe.com/t5/acrobat/validate-check/m-p/11827531#M297762 

check @Nesa Nurani post of how to use variables instead of giving checkbox value.

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
Explorer ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

yes but it didnt work / I couldn't figure out how to make it work 

 

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
Explorer ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

I should also add that all 3 checkboxes can get checked and add to the overall total 

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
Enthusiast ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

So you want to add value to checkbox if checked and also that checkbox to have another value that will add to total if checked?

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
Explorer ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

Ok  So I have 2 drop downs that are dependent (below) When Exterior is selected in the "package type" drop down I would like "paint check" "engine check" and "ceramic check" to have a value of 150, 35 and 200 respectively but if Full Package is selected I would like the same 3 check boxes to have a value of 180, 45 and 400 respectively. (I want to avoid having multiple checkboxes to hide and show) I only want those values to be calculated to the "addon total" box when then checkbox(es) are checked 

 

so in non code language I am looking for: If Exterior is selected give value of 150 to paint check if checked. addon total sum = paint check, engine check, ceramic check. 

 

 

Screen Shot 2021-02-23 at 2.53.54 PM.pngScreen Shot 2021-02-23 at 2.54.07 PM.png

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 ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

Try using code in "custom calculation script" of dropdown field "package type":

var v1 = 0;
var v2 = 0;
var v3 = 0;
if(event.value == "Exterior" && this.getField("paint check").valueAsString != "Off")
v1 = 150;
if(event.value == "Exterior" && this.getField("engine check").valueAsString != "Off")
v2 = 35;
if(event.value == "Exterior" && this.getField("ceramic check").valueAsString != "Off")
v3 = 200;
if(event.value == "Full Package" && this.getField("paint check").valueAsString != "Off")
v1 = 180;
if(event.value == "Full Package" && this.getField("engine check").valueAsString != "Off")
v2 = 45;
if(event.value == "Full Package" && this.getField("ceramic check").valueAsString != "Off")
v3 = 400;
this.getField("addon total").value = v1+v2+v3;

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
Explorer ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

Nesa! Thank you! This works. 

 

How easy is it to add additional variables? 

 

Would I just add:

 

var v4 = 0;
if(event.value == "Exterior" && this.getField("example").valueAsString != "Off")
v4 = new price;

 

can I add unlimited "var v#" ? 

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 ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

Yes you can add more variables.

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
Explorer ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

Thank you for your help, one final question: How would I use radio buttons in the same scenario? ie I have a radio button group called "surcharge" one "radio button choice" name is "30" and the other one is "60" how would that fit in the variables list? If possible, if not all good just bonus if it can. 

 

 

Thanks!

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 ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

You can do it the same way just use their export value  like this:

instead of  valueAsString != "Off"   use

valueAsString == "30"

 

hope that helps.

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
Explorer ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

I tried that and it didnt work. I made sure I added v4 + v5 to the calculation of addon total but it didnt work. What did I do wrong?

 

Screen Shot 2021-02-23 at 11.41.50 PM.png

Screen Shot 2021-02-23 at 11.42.19 PM.png

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
Explorer ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

LATEST

Nevermind, I just realized I spelled "surcharge" wrong on the buttons! Ugh could you believe I've been staring at this for a few hours trying to figure out why it wasn't working?! lol Thanks for all your help 🙂

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