This content has been marked as final. Show 21 replies
Where 'NumericField' is the name of your field
Mark, I really appreciate your help. I tried your code line with many variations in the punctuation. The dialog box accepts it without any error messages but when I click on the resulting link, nothing happens to the value in the Numeric Field. Other links on the form work fine. Any other thoughts? Thanks, Fred
It works fine for me. Make sure that your field name is spelled properly, and is enclosed in quotes as above. Also, check that your numeric field is also valid.
this.getField("NumericField") has no properties
Mark, thanks again for your prompt reply. I think I'm becoming a nuisance to you.
I turned on the debugger and it gave me the exact message that you predicted. I had been using the name "NumericField10" as a name for the field. I thought that maybe that is not a good name as far as the link was concerned. So I changed the name to "Pointer". It did not fix the problem but I now get a different message from the debugger:
Pointer is not defined
I'm not sure what you mean when you ask whether my numeric field is valid, but I can write numbers into it and save them and a different link can reset them, so I guess it is "valid".
I do feel that we are getting close to a solution. Does the name of the field have to be declared somehow?
You have to enclose the field name in quotes, otherwise you will get that message (it's expecting a variable named Pointer if it's not in quotes). If your field is named Pointer, then the code should be:
Yes, that's exactly how I entered the code - several times. Still didn't work. Sorry to be so much trouble. F
Mark, another question. Do you know any other statements that do the same thing? My computer is obstinate. Maybe it doesn't like the one I have. F
What response are you getting?
If you make "Pointer"'s format to "None" what value appears?
An alternate approach that spells out the code and forces the value of "Pointer" to a numberic value or the number 0.
// increment field value of pointer by 1
this.getField("Pointer").value = 1 + Number(this.getField("Pointer").value);
Mark, I think I have figured out our problem!! You gave me the clue by asking what happens when I make the format "NONE". I think there is a "format" only in the control fields made with the FORMS menu in Acrobat. But my Numeric Fields are made in the LiveCycle Designer of Acrobat8. Since there are no "Numeric Fields" in the FORMS menu (Only "Text Fields" that can me made numeric), I didn't bother to explain that.
So these Designer forms are really XML forms, although the LINK PROPERTIES dialog box asks for Java statements. Maybe they must be different from the statements in the other kinds of forms. If that is the problem, it's all my fault and I'm sorry for all the extra work you did. You are a patient man.
Back on the subject of the Numeric Field, I also have a link on that form with an "action" to RESET the form. And it does reset my Numeric Field to a blank field. So some time ago, I looked at the Java code assigned to that link and it was something like this:
I tried making all kinds of changes in that statement to see if I could make it increment the field value instead of resetting, but nothing worked.
Does all that clear things up, or make them worse? Thanks again, F
PS The last statement you sent doesn't work either, but I hope we now knot why.
> although the LINK PROPERTIES dialog box asks for Java statements
> Maybe they must be different from the statements in other kinds of forms
If you're using LiveCycle Designer, you can increment the value of a Numeric Field as such:
NumericField1.rawValue = parseInt(NumericField1.rawValue) + 1;
Replace NumericField1 with the name you have given your numeric field.
Have a look at:
What is the name of your numeric field?
Geo Kaiser: Thank you too for that link. But the problem they are discussing there is much, much more complicated than mine. I found nothing there that I could extract for my simple task (partly because I couldn't understand much of it).
For "Pointer" it would be:
Pointer.rawValue = parseInt(Pointer.rawValue) + 1;
Again, this expression will not work if the script is being run from a different hierarchical level than Pointer resides in.
First, I tried that expression and it doesnt work. So now, as you suggested, I will go through the process I used to get to this point, leaving out no details because I dont know which detail might be important.
Start Adobe Acrobat 8 Professional, click FORMS on the Getting started screen, click CONVERT AN EXISTING DOCUMENT.
In the Create New Form dialog box, browse to a .BMP picture document that will be the background of the form. Two dialog boxes later, choose to place fields by hand. A couple of clicks gets the LiveCycle Designer on the screen.
On the Menu Bar, click INSERT and select the MY FAVORITES library and click on NUMERIC FIELD. Drag the Numeric Field to the document. Fill out all appropriate Pallets for Field, Value, Binding, Layout, and Format.
There are some 10 Numeric Fields in the document. The one we are particularly interested in here is NumericField10. It is set to be two digits long. Next to it is an arrow pointing up. I want to place a link over that arrow so that, when clicked, the value of the field is incremented. (I really wanted to put a Spin Button there like the one Microsoft Visual Basic has, but Adobe has no such button and Ive not been able to find one to insert into the library.)
Click SAVE AS on the LiveCycles Menu Bar. And save the document, which is now in .PDF.
Open the new PDF document. On the Acrobat Menu Bar, select ADVANCED and click on ENABLE USAGE RIGHTS IN ADOBE READER. Save the document again.
Open the document again in Acrobat to add links.
On the ADVANCED EDITING toolbar, click the LINK button.
Draw a rectangle around the UP arrow on the form. That brings up the CREATE LINK dialog box. Under Link Action select CUSTOM. That brings up the LINK PROPERTIES dialog box.
I hope that gives you all you need. Please tell me if you need more information. I cannot tell you how much I appreciate what you are doing. It means a lot to me. Thank you. Fred
Ah ... perhaps I'm getting my posts crossed, but I thought you had mentioned using LiveCycle Designer? The process you are using does not involve LiveCycle Designer and so the provided script will not work.
Try this in the same spot:
var fPointer = this.getField("Pointer");
fPointer.value = parseInt(fPointer.value) + 1;
But I did use LiveCycle Designer to make the Numerical Fields. See the third paragraph in my last message. It ends with "A couple of clicks gets the LiveCycle Designer on the screen." The next three paragraphs all take place in LiveCycle Designer. I should have made it clearer.
Does that change things? I tried the two statements that you sent and they didn't work. Sorry I mislead you. Fred
Unfortunately I sincerely do not recommend designing your forms in this method, since you are losing a lot of the new, advanced XFA functionality while restricting what you can even do with the older AcroForms technology.
I suggest you learn how to do your coding in LiveCycle Designer if you're going to be designing forms using it. XFA forms and AcroForms are VERY different, and not understanding that difference before diving into development is really what got you to this point.
Here is a link to the Adobe LiveCycle Designer Scripting Examples. Once you understand how to add XFA code to XFA forms, you'll be able to get what you need done.
You have finally made me understand the entire situation and steered me in the right direction.
I'm very grateful to you for your patient and steadfast help and all the time it took to give it. Thank you, Fred
PS And thanks to the others who also pitched in to help. I'm now able to use some of the code that you sent.