Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Changing field appearance programatically?

_Bill_Bain_
Level 4
Level 4
We have a user form that is filled out and then printed. I would like to change the appearance of the fields from Sunken Box to None prior to printing to make the printed copy look less like a form. I've not been able to locate a property that corresponds to the Appearance option in Designer. It seems like there should be one available in either Javascript or FormCalc, but I've not been able to locate one. Is there such an "animal" and if so, what is it?



Thanx!



Bill Bain

Atlanta
0 Replies
pguerett
Level 10
Level 10
I am assuming it is only fields that you want to change. Try this:



Fieldname.ui.textEdit.border.presence = "hidden";



To put the border back make the presence = "visible"
_Bill_Bain_
Level 4
Level 4
Thanks! That worked. Now all I have to do is make it loop through all the fields in the form. Not sure exactly how to do that . . . .
pguerett
Level 10
Level 10
I have a sample ...post your email address and I will send a sample.
_Bill_Bain_
Level 4
Level 4
Thanks for the help!



bill_bain@hotmail.com
_Bill_Bain_
Level 4
Level 4
I'm not following why the following doesn't work. I found an example in the Scripting reference for setting the access to "protected." It reports that ui.textEdit has no properties, however the statement changing the access property does work:



//Get the field containers from each page.

for (var nPageCount = 0; nPageCount < xfa.host.numPages; nPageCount++) {

var oFields = xfa.layout.pageContent(nPageCount, "field");

var nNodesLength = oFields.length;



//Set the field Property

for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++){

oFields.item(nNodeCount).ui.textEdit.border.presence = "hidden";

oFields.item(nNodeCount).access = "protected";

}

}



This statement also works:



form1.Page1.Cust_No.ui.textEdit.border.presence = "hidden";



I'm officially baffled.



Bill Bain

Atlanta
pguerett
Level 10
Level 10
Just sent you the sample.



Regarding your next post .....I would put an app alert after the

var nNodesLenth = oFields.length

statement to see if oFields is getting populated with objects.



Assuming it is ....then put an app alert after you get a single object inside of the for loop to ensure that you are dealing with an object:



app.alert(oFields.item(nNodeCount).ui.textEdit.border.presence)
_Bill_Bain_
Level 4
Level 4
I took your advice and added a couple of app.alerts to help figure out what's going on. I'm not following the code in your .xdp example very well, particularly since I'm new to Adobe.



This one came in quite handy:

app.alert(oFields.item(nNodeCount).name)



the message "XFA:form1[0]:Page3[0]:Button1[0]:click



form1.Page1.RM_Data_Fee.ui.textEdit has no properties"



seem to come up on check boxes AND Numeric fields -- the looping works fine until it hits one of those field types. At that point I get the message. It's kludgy, but for a laugh I moved the check boxes all up in the hierachy and then started the nodeCount with the next number (e.g., moved 2 check boxes and then started the nodeCount with 3) and it ran until it hit a numeric field (!).



I also tried hard coding the border change:



CheckBox1.ui.textEdit.border.presence = "hidden"



and sure enough the check boxes don't have properties? OK, but why it is not processing the numneric fields?



Thanks for your help!



Bill
pguerett
Level 10
Level 10
There is a case in there for checkboxes and numeric fields. For the ones that fail but a message box in and make sure that we are checking for the right className
_Bill_Bain_
Level 4
Level 4
the className property in all cases is giving me "field" as it loops through, for both checkboxes and numneric fields.



I feel like there's something I'm missing that should be really obvious. It's just no supposed to be this hard . . . .
pguerett
Level 10
Level 10
Send the form to livecycle8@gmail.com and I will have a look when I get a chance.
_Bill_Bain_
Level 4
Level 4
Paul -



Thanks for the help. The script worked perfectly -- I added some app.alerts in various points to understand what was going on. I hadn't thought about using scripts -- that's a great idea.



I do have another issue that's arisen -- I want to use the Reader Extensions so that the users can email the completed form. After the script runs, the screen looks perfect. However if they either save the completed form or email the form, what gets saved or emailed is the form with the data, however, none of the formatting that the script applies (hiding borders, protecting fields) is in the emailed or saved copies. It's like the script never ran. I tried running the script as a preSave event, instead of on a button click before using "File, Save", but I can't add the Reader Extensions because it runs the script when I try to save the form in Acrobat (after adding the extensions)!



Why would the screen look perfect but the saved form not match the screen?



Baffled again . . . .



Bill
pguerett
Level 10
Level 10
On the Form Properties under the Defaults tab there is a Radio Button that indicates whether to keep the state of the form that the script changes has done or not. Change the radio button to automatic and try it again.
_Bill_Bain_
Level 4
Level 4
Nuts. I get the following error message:



"1305 Static PDF Form

Dynamic XML Form Target version does not support the Preserve Scripting Changes To Form When Saved option. Select File > Form Properties, click the Defaults tab and, under Preserve Scripting Changes to Form When Saved, select Manually."



The documentation indicates that Reader 8.0 is required. The form has to run with Reader 7.0.5. So how do I preserve the scripting changes manually/can Reader 7.X do this?
pguerett
Level 10
Level 10
Nope ...we have to do it through script when we load. We will need to know that we have to display without borders so we can have a hidden field that will act as our flag. If we populate the hidden field with a known value when we click the button that prepares our form then we can check the status of the flag and act accordingly. The event you want to do this on is DocReady (at the form1 node) then simply:



if (flag.rawValue == "whatever"){

call border hiding code again

}
_Bill_Bain_
Level 4
Level 4
Hah! Now I understand. Putting the code in the docReady event causes the code to operate when the form is opened by the *recipient*! Neat! It works perfectly.



Thank so much for the help!



Bill