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

syntax error 4: at line 5

RustyWood
Registered: Mar 16 2010
Posts: 83

Hi can someone let me know if I am on the right track with this calculation

and also why I'm getting a "syntax error 4: at line 5"

var a = this.getField("Check_Box_1").value;
if(a == 1) 
//event.value = No_cards_in_pack_Row_1 * 0.35;  //  
else if (b < = 1)
var b = this.getField("more_than_1_pack_state_quantity_Row_1").value; //
event.value = pack_price_10_per_cent_off_2_or_more_Row_1 * b;//

With Thanks

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
White space can be used to separate objects, and operands and not let JavaScirpt try to make the decision. So one should not place spaces or blanks within the string for an operator.

The less than or equal operator is '<=' and not '< ='.
var a = this.getField("Check_Box_1").value;if(a == 1)//event.value = No_cards_in_pack_Row_1 * 0.35;  else if (b <= 1)var b = this.getField("more_than_1_pack_state_quantity_Row_1").value;event.value = pack_price_10_per_cent_off_2_or_more_Row_1 * b;

The '//' string is the value used to mark the start of a single line comment. The ';' is the JavaScript line terminator. There is also a pair of marks for marking multiple line comments.

George Kaiser

try67
Expert
Registered: Oct 30 2008
Posts: 2398
You should also remove the // before the beginning of line 3. It causes an illegal if statement.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
In running your code I have found that you have not defined a number of variables or you are not accessing the field object for the named fields, 'No_cards_in_pack_Row_1' and 'pack_price_10_per_cent_off_2_or_more_Row_1'.

Also what is the value of 'Check_Box_1' when checked?

George Kaiser

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Also, you're trying to check the value of b before defining it.
Bottom line, this code has more errors than correct lines...

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

RustyWood
Registered: Mar 16 2010
Posts: 83
Yeh thanks for trying try67 but

gkaiseril has been more than helpful and very correct on many answers.

thanks again gkaiseril
RustyWood
Registered: Mar 16 2010
Posts: 83
Already removed //

The check box value is 1 which = a variable amount of cards * 0.35

Once more than 1 pack is ordered then 1st pack and 2nd pack also becomes minus 10%

yes I'm not accessing the field object for the named fields agreed

"No_cards_in_pack_Row_1" is where amount of cards is typed in

"pack_price_10_per_cent_off_2_or_more_Row_1" is the total minus 10%

thanks