Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

Dynamic Captions

Avatar

Former Community Member
Hello,

I have a text field that I want to display a caption with some built in scripting. For the Caption of the field I want to display part of the text that displays as static text in a regular format, while populating the second part of the caption with the value of a variable. For this second part of the caption I want to give the text an italic look. I can see how this is done when everything is static in the caption (going through the field/caption/value/exData/body tags in the XML for my form. Is there a way to set this up dynamically though through scripting.



I know for a work around I could just have two fields. One without a caption (that would represent my current text field, just remove the caption), and a second that would have my static caption, and have the field be the value that I display in italics. I was just wondering if there was a way to dynamically edit the caption of a field.
4 Replies

Avatar

Former Community Member
I have been looking into this and have found that you can only dynamically change the rich text caption if the form is dynamic and not if it is static.



This is not as simple as it sounds and I am working on a prototype for you.



I will post the results when I am complete.

Avatar

Former Community Member
My testing is complete.....you have to create a variable that will hold the rich text formatting (in html format) that you will set in the caption. Then you need to load that variable into the appropriate property. It will look like this:



rt = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><body xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:xfa=\"http://www.xfa.org/schema/xfa-data/1.0/\" xfa:APIVersion=\"2.8.8028.0\"><p style=\"letter-spacing:0in\">Kyle <span style=\"xfa-spacerun:yes\"></span><span style=\"font-weight:bold;text-decoration:underline\">Black</span></p></body>"

FFRichField2_JS.caption.value.exData.loadXML(rt,0)



A couple of things to keep in mind:



- The form needs to be dynamic

- You need to escape (\) the double-quotes () in the script in order for it to work

- I dont know how much of the namespace stuff you need, I just copy and pasted it from the XML source.....so set up a caption the way you want and copy and paste the exData segment so you can see how the attributes are set.

Avatar

Former Community Member
Paul,

Thanks for the response. I figured there had to be a way to interject some html into the caption to do this, but I just couldn't figure out how exactly to accomplish that. While I ended up just breaking up my form and added two fields where I had just had the one before. I will go back and see if I can't get this to work. Thanks again, and I hope others find this useful as well.

Avatar

Former Community Member
I needed to do the same thing, but in a static text field. It worked like a charm until I enabled Extended reader functions. Now I get "Invalid node type: body" on both Acrobat Pro 9 and Reader 9!



So now I have to choose between formatting in the text field or allowing users to save the document. Any Ideas?



Nevermind - I was being lazy and abbreviating the body tag to just .