These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

conditional calc based on radio button

banar
Registered: Mar 10 2010
Posts: 6

This should be easy but I cannot figure it out.

I'm working on the product selection page, where clients can click next to each product if they want to order it or not.

I have 2 radio buttons YES and NO. Radio button name is radio5

If the client selects YES I want the value of the price5 change to 39. If NO, the price should change to 0.

if (radio5=="YES") price5=39;

I know it's half of the code but it's not working, please help.

Thank you in advance.

My Product Information:
Acrobat Pro 9.2, Macintosh
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Your explination is not complete.

George Kaiser

Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi banar,

This tutorial on writing conditional statements should help you out-
http://www.acrobatusers.com/tutorials/conditional-execution

Hope this helps,

Dimitri
WindJack Solutions
www.pdfscripting.com
www.windjack.com
banar
Registered: Mar 10 2010
Posts: 6
gkaiseril wrote:
Your explination is not complete.
What else would you need to understand it better? Am I missing something?
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
And mine certainly does not provide enough information for obtaining more information.

Where exactly are you placing this script?

It appears to be a 'simplified field notation' script. And that type of calculation has many restrictions on field names, value types, and allowed operations (no functions, no field properties, no field methods, not conditional logical test, no flow control). Are you getting any JavaScirpt console messages?

What are the values for the "Yes" and "No" options?
You could set the "Yes" value to 39 and the "No" value to 0.
Is one of the check boxes set to be checked by default?
If you set the "No" button to be checked, then the value in the calculation would be 0.

So with a Radio Button pair named 'radio5' the "Yes" button choice has a value of 39 and the "No" button value has a value of 0. For the "No" option set the select the 'checked by default' option. Then your code the "pirce5" field could have a 'simplified field notation' calculation of:
radio5
Radio buttons and check boxes have a string value of 'Off' when not selected.

There are at least 3 different ways to calculate a field value on the caculate tab, so one really needs to specify which one of the options has been used.

George Kaiser

banar
Registered: Mar 10 2010
Posts: 6
It looks like it works, THANK YOU,

I will let you know soon.
banar
Registered: Mar 10 2010
Posts: 6
Thank you gkaiseril, It works.