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

else is statements

geiszler
Registered: Jun 7 2010
Posts: 8
Answered

Hi, I'm fairly new to writing javascript in acrobat. I'm having an issue with the code below.

This is what I'm trying to say...
IF F3 greater then 800001 take 250000-F4
IF F3 greater then or equal to 250000 the the value equals 250000
IF F3 less then 250000 then the value should be F3

Does any one have a good example?

Here is my code...

var F3 = this.getField("F3").value;
var F4 = this.getField("F4").value;
 
if ( F3 > 800000) {
	event.value = 250000 – F4; }
else if ( F3 >= 250000) {
	event.value = 250000;  }
else { event.value = F3; }

I keep getting an error saying Illegal character 5: at line 6

Does anyone know what I am doing wrong? I would appreciate any help! Thanks!

My Product Information:
Acrobat Pro 9.3.1, Windows
Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi geiszler,

This tutorial from the Learning Center here discusses writing conditional statements for PDF forms-
http://www.acrobatusers.com/tutorials/conditional-execution

The minus sign used in Line 5 is causing an error- these type errors can be seen if you use something like a Word Processor for writing code then copy from it- illegal characters, extra carraige returns and wrong quote types are common problems. You should always use a plain text editor like Notepad, etc.

Hope this helps,

Dimitri
WindJack Solutions
www.pdfscripting.com
www.windjack.com
geiszler
Registered: Jun 7 2010
Posts: 8
Thanks for your quick respone. I tried that and I'm still having issues...I get the same error. Thanks for trying to help a very confused person.

Here is my revised code...


var F3 = this.getField("F3").value;
var F4 = this.getField("F4").value;

if( F3 > 800000)
event.value = 250000 – F4;
else if( F3 >= 250000)
event.value = 250000;
else
event.value = F3;
Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi geiszler,

See the additional text in my earlier reply.

Hope this helps,

Dimitri
WindJack Solutions
www.pdfscripting.com
www.windjack.com
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Dimitri is right. Use this code (copy&paste it) instead of the one you have now:
var F3 = this.getField("F3").value;var F4 = this.getField("F4").value; if( F3 > 800000)event.value = 250000 - F4;else if( F3 >= 250000)event.value = 250000;elseevent.value = F3;

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

geiszler
Registered: Jun 7 2010
Posts: 8
It worked!!!! Thanks for all your help!
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Specifically, your '-' is not the ASCII plain text minus sign.

It has a character decimal value of 150 and not 045. [url=http://www.asciitable.com/]ASCII Table[/url]

You have to use a very simple text editor like NotePad. [b]Not[/b] MS Word or WordPad!

George Kaiser