I'm trying to get the border of the fillable area of a text field to change color. So far the only way I have found to get all four sides to change is by using the following lines of code.
xfa.resolveNode("TextField1.ui.#textEdit.border.edge[0].color").value = "0,255,0";
xfa.resolveNode("TextField1.ui.#textEdit.border.edge[1].color").value = "0,255,0";
xfa.resolveNode("TextField1.ui.#textEdit.border.edge[2].color").value = "0,255,0";
xfa.resolveNode("TextField1.ui.#textEdit.border.edge[3].color").value = "0,255,0";
I thought maybe I could use a for loop to do the same thing as in the following.
for(var i = 0; i < 3; i++)
{
xfa.resolveNode("TextField1.ui.#textEdit.border.edge[i].color").value = "0,255,0";
}
But I get the following error when I click the button that the script is attached to.
GeneralError: Operation failed.
XFAObject.resolveNode:6:XFA:form1[0]:MainPageSF[0]:Button1[0]:click
Malformed SOM expression: TextField1.ui.#textEdit.border.edge[i].color
I don't know what is happening. Any ideas why a for loop doesn't work in this case?
for(var i = 0; i < 3; i++)
{
xfa.resolveNode("TextField1.ui.#textEdit.border.edge[" + i + "].color").value = "0,255,0";
}
Or you could do it like this:
var nodes = xfa.resolveNode("TextField1.ui.#textEdit.border.edge[*].color");
for(var i = 0; i < 3; i++)
{
nodes.item(i).value = "0,255,0";
}
However, you shouldn't have to access all of the edges unless it was setup like this in the first place. Have you looked at the original XML to see how the field was initially structured?
Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]
The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]
Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script