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

Having trouble this calculation

RustyWood
Registered: Mar 16 2010
Posts: 83
Answered

Need a little help please, this is my problem.

Only if the participant purchases an 3 items for 11.50, then they have the option to purchase more at 3.00 each,

the event . value of (b* 3.00) is working but event.value a is sticking at 11.50 on which ever radio button I press, the additional pack box is hidden until check box 3 = 11.50 is checked

var a = this.getField("partcipant_1_check_box").value;
if(a == 1)
  event.value = 5.25; // 
else if (a == 2)
    event.value = 9.00; // 
else if (a == 3)
    event.value = 11.50; // 
 
var b = this.getField("participant_1_quantity_additional_packs").value;
if (a = 11.50 ) 
event.value = a + (b * 3.00)//

Any help would be great
Thanks in advance
Rusty

My Product Information:
Acrobat Standard 9.0, Macintosh
jimhealy
Team
Registered: Jan 2 2006
Posts: 146
Quote:
if (a = 11.50 )
Here you are assigning 11.50 to a. You need:if (a == 11.50 )
Jim Healy
FormRouter, Inc.
Check out our FREE Advanced Acroform Toolset:
http://www.formrouter.com/tools

Jim Healy, Founder & CEO FormRouter Inc.
Chapter Leader AUG RTP NC
http://www.formrouter.com

RustyWood
Registered: Mar 16 2010
Posts: 83
Thanks Jim

I have tried that before, but that seems to cancel out the (b*3.00) calculation??

True I do get the radio button values back

thanks again
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Look carefully at your code, you maybe looking at the wrong value. It appears you want to test 'a' for a value of '3' items. Then the price is '11.50' plus 3 times the extra packets purchased. You could also see if the event.value is equal to '11.50'.

George Kaiser

RustyWood
Registered: Mar 16 2010
Posts: 83
Thanks I'm not sure how to test "a" for the 3 values

I tried this thinking if the value of a was greater than 11.50 ??

var a = this.getField("partcipant_1_check_box").value;if(a == 1)event.value = 5.25; // else if (a == 2)event.value = 9.00; // else if (a == 3)event.value = 11.50; //  var b = this.getField("participant_1_quantity_additional_packs").value; if (a >= 11.50 )event.value = a + (b * 3.00)//

Rusty
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Lets look at your code with meaningful comments and variable names added.
// get the number of participant packsvar ParPacks = this.getField("partcipant_1_check_box").value;// assign price based on number of participant packs selectedif(ParPacks == 1) {// one item selectedevent.value = 5.25;  // total 5.25} else if (ParPacks == 2)  {// 2 items selectedevent.value = 9;  // total 9.00} else  if (ParPacks >= 3 )  {// 3 or more items selected// get number of additional items  var AddPacks= this.getField("participant_1_quantity_additional_packs").value;// compute value   event.value = 11.5 + (AddPacks * 3.00); // 11.50 + ( number of additional packs * 3.00)}

The value of the number of participants packs is not chaged and will not equal $11.50. $11.50 is the value of the field.

George Kaiser

RustyWood
Registered: Mar 16 2010
Posts: 83
Thanks very much this is perfect ,

I'm going through it to understand what is actually going on the last section

Thank you again for all your help

Rusty
krickett47
Registered: Feb 4 2010
Posts: 18
Can anyone tell me what is wrong with this code?

var a = this.getField("201").value;
var b = this.getField("200").value;
var c = this.getField("213").value;
// compute the value
event.value = '';
if( c != 0) {
// perform only is b / c is not zero
event.value = b / c
}
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
You should start a new post and not high jack this post.

George Kaiser

RustyWood
Registered: Mar 16 2010
Posts: 83
To gkaiseril

Thank you for your calculation

I'm a bit confused on why and when you use these signs

(== )

and

{ }

other than that I do understand the logic behind the calculation (not that I would be able to write it yet)


// get the number of participant packsvar ParPacks = this.getField("partcipant_1_check_box").value;// assign price based on number of participant packs selectedif(ParPacks == 1) {// one item selectedevent.value = 5.25;  // total 5.25} else if (ParPacks == 2)  {// 2 items selectedevent.value = 9;  // total 9.00} else  if (ParPacks >= 3 )  {// 3 or more items selected// get number of additional items  var AddPacks= this.getField("participant_1_quantity_additional_packs").value;// compute value   event.value = 11.5 + (AddPacks * 3.00); // 11.50 + ( number of additional packs * 3.00)}

Thank you again

Rusty
jimhealy
Team
Registered: Jan 2 2006
Posts: 146
Testing for equality in Javascript uses ==. If you use = you are assigning a value to a variable. As far as the braces, they are used to group lines of code into blocks (it is a scope thing). If you have an if statement with more than one line to be executed when the condition is satisfied, you need to use braces around all the lines that you want to be executed.

Jim Healy
FormRouter, Inc.
Check out our FREE Advanced Acroform Toolset:
http://www.formrouter.com/tools

Jim Healy, Founder & CEO FormRouter Inc.
Chapter Leader AUG RTP NC
http://www.formrouter.com

RustyWood
Registered: Mar 16 2010
Posts: 83
Thank you Jim every bit of advice helps

Thanks again
RustyWood
Registered: Mar 16 2010
Posts: 83
Hello

I have had to change the radio boxes to check boxes which I was using before, so I could have an easier count total.

But now I have the problem of getting the values of three separate check boxes into this calculation as you may see
I'm sure this is totally wrong as it's not working I get a return of 5.25 off "participant_1_check_box_1" but nothing off "participant_1_check_box_2","participant_1_check_box_3" or "participant_1_quantity_additional_packs"

Again any insight into this would be appreciated

Thanks



// get the number of participant packsvar ParPacks = this.getField("participant_1_check_box_1","participant_1_check_box_2","participant_1_check_box_3").value;// assign price based on number of participant packs selectedif(ParPacks == 1) {// one item selectedevent.value = 5.25;  // total 5.25} else if (ParPacks == 2)  {// 2 items selectedevent.value = 9;  // total 9.00} else  if (ParPacks >= 2 )  {// 3 or more items selected// get number of additional items  var AddPacks= this.getField("participant_1_quantity_additional_packs").value;// compute value   event.value = 11.5 + (AddPacks * 3.00); // 11.50 + ( number of additional packs * 3.00)}
RustyWood
Registered: Mar 16 2010
Posts: 83
Think I've got it !!!!


// get the number of participant packsvar a = this.getField("participant_1_check_box_1").value;var b = this.getField("participant_1_check_box_2").value;var c = this.getField("participant_1_check_box_3").value;// assign price based on number of participant packs selectedif(a == 1) {// one item selectedevent.value = 5.25;  // total 5.25} else if (b == 2)  {// 2 items selectedevent.value = 9;  // total 9.00} else  if (c >= 2 )  {// 3 or more items selected// get number of additional items  var AddPacks= this.getField("participant_1_quantity_additional_packs").value;// compute value   event.value = 11.5 + (AddPacks * 3.00); // 11.50 + ( number of additional packs * 3.00)}