Let say you have text box 1, text box 2 and text box 3 on a form.
In text box 3 you have a Calculation script so it displays whatever is typed in to text box 1 and text box 2.
Can you also have in text box 3's script, a way to display text box 1 in a certain style, and text box 2 in a different style?? So basically two text styles in one calculated text box?
Thank you
Solved! Go to Solution.
Views
Replies
Total Likes
I was curious enough myself to try it.
It is due to the multiple top level nodes in the XML that I suspected would be a problem. I love the error too:
Xml parsing error: junk after document element (error code 9), line 8, column 2 of file
The below worked for me to blend the two together. What may seem weird is that if you are thinking it will copy the formats set at design time, it won't. It's like the design time format is the default for the field and the XML does not contain that format. If I select part of one of the fields, right click and change the text formating, that will get copied over. If your intent was for it to copy the design time format, you'll probably be better off building the XML string yourself and insert the CSS format. Pull up the JavaScript console and look at the XML to get a starting point.
var richText = TextField1.value.exData.saveXML();
var richText2 = TextField2.value.exData.saveXML();
console.println(richText);
console.println(richText2);
//crude way to blend the two XML docs into one
var richText3 = richText.substring(0, richText.indexOf("</body")) + richText2.substring(richText2.indexOf(">", richText2.indexOf("<body")) + 1);
console.println(richText3);
TextField3.value.exData.loadXML(richText3,1,1) ;
Views
Replies
Total Likes
On the Field tab for Text Box 3, set the Field Format to Rich Text. The other two may need to be as well. Then this should help: http://help.adobe.com/en_US/livecycle/9.0/designerHelp/index.htm?content=000838.html
thanks for that.
Using the example you gave from the adobe site, how can I adapt that code so that 2 or more textboxes can be copied to make the combined text box. I've tried many options but just can't get it. Must be something like:
var richText = TextField1.value.exData.saveXML();
var richText2 = TextField2.value.exData.saveXML();
TextField2.value.exData.loadXML(richText,1,1) + (richText2,1,1) ;
Can anybody suggest how to make the above work?! Thanks
Views
Replies
Total Likes
The first thing I would try is:
TextField2.value.exData.loadXML(richText + richText2,1,1) ;
I don't know what the xml looks like though. You might have an issue with there being two top level nodes.
Views
Replies
Total Likes
Cheers but no joy
Views
Replies
Total Likes
I was curious enough myself to try it.
It is due to the multiple top level nodes in the XML that I suspected would be a problem. I love the error too:
Xml parsing error: junk after document element (error code 9), line 8, column 2 of file
The below worked for me to blend the two together. What may seem weird is that if you are thinking it will copy the formats set at design time, it won't. It's like the design time format is the default for the field and the XML does not contain that format. If I select part of one of the fields, right click and change the text formating, that will get copied over. If your intent was for it to copy the design time format, you'll probably be better off building the XML string yourself and insert the CSS format. Pull up the JavaScript console and look at the XML to get a starting point.
var richText = TextField1.value.exData.saveXML();
var richText2 = TextField2.value.exData.saveXML();
console.println(richText);
console.println(richText2);
//crude way to blend the two XML docs into one
var richText3 = richText.substring(0, richText.indexOf("</body")) + richText2.substring(richText2.indexOf(">", richText2.indexOf("<body")) + 1);
console.println(richText3);
TextField3.value.exData.loadXML(richText3,1,1) ;
Views
Replies
Total Likes
Here I changed TextField1 to Bold and 2 to Italic. Those were also what I entered for text.
<?xml version="1.0" encoding="UTF-8"?>
<exData contentType="text/html" xmlns="http://www.xfa.org/schema/xfa-template/3.0/"
><body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"
><p style="margin-top:0pt;margin-bottom:0pt;text-valign:middle;font-family:'Myriad Pro';font-size:10pt;font-weight:bold;text-decoration:none"
>Bold</p
><p style="margin-top:0pt;margin-bottom:0pt;text-valign:middle;font-family:'Myriad Pro';font-size:10pt;font-style:italic;text-decoration:none"
>Italic</p
></body
></exData
>
Just read your reply. I can't test it out until I'm back at work, but really appreciate your help. Will update when I give it a try
Views
Replies
Total Likes
Thats great it works well. When it comes together in tb3, tb1 and tb2 appear on two seperate lines.
Im going to ammend the code to get 6 textboxes in to the one textbox. I need two on the same line with a space in between (" "), then two on the next line and then two on the next line. So 3 lines of 2 next to each other with a space in between.
As you say I need to build the xml string.
Views
Replies
Total Likes
I would just build the XML string. You need the header stuff, the style for Field 1, then rawValue from Field 1... then footer stuff.
The reason they are on separate lines is the <p> and </p> tags. The code I posted strips the </body> tag on from the first field and everything up to and including the <body ...> tag from the second one. If modified to strip the paragraph tags too, they would be on one line. Of course, the style is in the paragraph tag so it would get lost. You could replace <p with <span and </p with </span
Views
Likes
Replies
Views
Likes
Replies