Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Variable scripting

Avatar

Level 3

Hello everyone.  I have an issue trying to figure out how to design a particular script... I have a check box that will unhide a subform.  Once the subform is present, there is a numeric field asking for a quantity, there is a drop down box that asks the user to select either 8oz or 12oz and then there is a final numeric field that will calculate the total.  My problem is how to calculate my total based off the selected weight and quantity. 

When the form becomes visible, the user will enter a quantity, she will then select the size and this is where I believe I have to place a script with the checkbox that presented the subform.  Right now, for all the other subforms, it is rather simple math (there is no size to factor in) using Formcalc.  The simple ones are STqty * 10.99 which renders a total cost.  The challenge with the different sizes is how to build the script.  I'm thinking something like STqty * a value derived from a variable giving me the total cost.  I just cannot seem to put 2 and 2 together on this one.  Also, I am looking at the script below as a possible solution, but wouldn't know where to place this script.

Please help.

Very respectfully

Mike

if (STsize=8oz)

            {

            STcst=”10.99”;

            }

else

            {

STcst=”12.99”;

}

10 Replies

Avatar

Level 5

Could you insert a script from your PDF with the hierarchy or could you upload your PDF?

This would be easier to help you.

Kind regards Mandy

Avatar

Level 3

I created a link at Adobe.com so that you could take a look at the file.  I hope that you can view the file, but if you can't, I could upload it directly to you... assuming you would allow that.

Thank you very much for offering to help with this.

v/r

Mike

http://creative.adobe.com/share/7e92e2f0-731c-4114-a06a-c9151ee5e23b

Avatar

Level 5

Hi,

I couldnt get access to your file.As per my understanding

If STcst is a Global variable then you keep the above script on the exit event of the drop down box.

If that doesnt work then mail me your file muchukotavijay@gmail.com so that i can have a look at it ..

Thanks

Vjay

Avatar

Level 5

Mike,

Now your file is working mailed you ..

There are two mistake in your script.

1.  "=" Assignment Operator , "==" Comparison Operator.

2. ”10.99”  and "10.99". Double quotes are not same in both the values.

I couldnt identify when i went through the code first time.

Vjay

Avatar

Level 3

Vjay, I apologize for bothering you again. Could I appeal to you to look at the file again and tell me what I'm doing wrong with the math on the total cost? I want to calculate all the instances (up to 6) of steak dinners. I thought my FormCalc script looked fine but for some reason it is not working (does not add the multiple instances)

Thank you very much and please know that if I am bothersome, you can tell me.

Thank you very much in advance!!

Best regards,

Mike

Avatar

Level 5

No Problem mike.

Replace the script in NumericField1 with the below script.

sum(form1.Page1.MENUchoiceMAIN.STdinSF.STdin[*].STdinCST.rawValue)

Have sent the file to you check it.

Thanks

Vjay

Avatar

Level 3

Vijay, your solutions have worked GREAT. I now have another challenge... I added some script to the steak check box to make the quantity value = 0 if the check box is unchecked. It works.. as long as I do not add multiple instances.. For instance... I add the first steak and then UNselect the check box and the total cost goes BACK to 0. If I instead another instance of the steak (2 entries) and then UNselect the check box, it will only ZERO the first entry, leaving the second one in the calculation, where I want the total to be a FULL zero if the check box is UNselected.

Vijay, please let me know if I am seeking too much help from you. You have quite frankly been the most helpful out of all on these forums and I am so appreciative, BUT I know I can sometimes ask too many questions. My feelings wont be hurt.

Regardless, I appreciate your help and will respect your decision.

Best regards,

Mike

Avatar

Level 5

Mike,When the check box is checked do you want to remove already added rows also or is it enf to make the quantity zero?

Not a problem you can ask me as many questions as you can ....

If you want to reset only The values then add the below script on change of streak.

xfa.host.resetData("form1.Page1.MENUchoiceMAIN")

Thanks

Vjay

Avatar

Level 3

Thank you Vijay

I would like the original AND all other instances removed AND all values to be ZERO

Thanks again Vijay... you are a huge help and I am learning so much!

Best Regards,

Mike

Avatar

Level 5

Mike,

Below are the two lines i have added on click of the steak checkbox.

xfa.host.resetData("form1.Page1.MENUchoiceMAIN")

form1.Page1.MENUchoiceMAIN.STdinSF.STdin.instanceManager.removeInstance(1)

This is script on click of the "Steakckbx14" check box

MENUchoiceMAIN.STdinSF.presence = "hidden"

if (this.rawValue == "1"){

          MENUchoiceMAIN.STdinSF.presence = "visible";

}

xfa.host.resetData("form1.Page1.MENUchoiceMAIN")

form1.Page1.MENUchoiceMAIN.STdinSF.STdin.instanceManager.removeInstance(1)

Vjay