Copy link to clipboard
Copied
I have a fillable form that has several hidden fields. When a choice is made from one of the drop down lists, then one of the hidden fields will appear. As there are several drop downs that have the same options, what I am hoping to do is have the hidden field appear at a specific set of coordinates on the form. If the user chooses the same option from one of the other drop downs, then the same hidden field may appear at a different set of coordinates. Does that make sense?
I have been shooting in the dark. Making the field appear is not the problem. I am using the following to make the field appear. I don't know how to get it to appear at specific coordinates like x=510 and y=77 or oCoords: [510,77,580,59]; etc.:
this.getField("Test").display = display.visible;
Thoughts?
Copy link to clipboard
Copied
You can set the property "rect".
Copy link to clipboard
Copied
I'm confused how to use rect. Isn't that normally used to draw a rectangle? I already have a predesigned field ready, I just need have it appear at the right coordinates. What coding would you use in this case?
Copy link to clipboard
Copied
You can read and set it with this.getField("Test").rect
Copy link to clipboard
Copied
So, I didn't get a specific answer from the thread that solved my issue, but I did find a work around using the this.addField and then referencing the field I wanted to appear and the coordinates where I wanted.
Copy link to clipboard
Copied
The answer above is the correct one. If you used addField then you've done the same thing as was suggested, ie. to set the rect property of the field. In addField it's the last parameter, but you can also use it on an existing thing, like this:
this.getField("Text1").rect = [x1, y1, x2, y2];
Copy link to clipboard
Copied
I changed the code to read how you had it, but the hidden field "Luca" still does not appear. I know I'm not the greatest at this, but I still can't see what I'm missing. Here is what I put:
this.getField("Luca").rect = [144,474,306,424];
I need the field "Luca" to go from hidden to visible at the specified coordinates when Luca is chosen from the drop down and then I need it to go back to hidden if another option is chosen in the same drop down field.
Sorry for the headache.
Copy link to clipboard
Copied
You need to do a little debug to figure things out. To do this use the the console window to run sample code for placing the field. i.e. make the "Luca" field visible. Open the console window. Enter the code for changing the rectangle, then run it. See what happens. enter different coordinates and run the code. This is how code development is done. You don't just enter large amouts of code that you have no idea of how it works. You create little tests to figure it all out.
You'll find a tutorial here on using the Console Window.
https://www.pdfscripting.com/public/Free_Videos.cfm#JSIntro
Copy link to clipboard
Copied
You must also change the property display.
Copy link to clipboard
Copied
So do you then delete the field when you want it hidden? This is a really bad plan. Bernd gave you the correct and simple answer. Just change the "rect" property of the field.
Copy link to clipboard
Copied
There's no need to guess what "rect" does, it's in the manual. You will always need to look up a method or property before coding it...
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more