Expand my Community achievements bar.

SOLVED

How to interact xfa attribute with javaScript

Avatar

Level 2

I want to change text with bold font in javaScript. How can I update <p> with required attribute in javaScript?

<draw x="9.525mm" y="69.85mm" minH="5.08mm">

            <font typeface="Verdana" size="9pt"/>

            <value>

               <exData contentType="text/html">

                  <body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"><p style="text-decoration:none;letter-spacing:0in">Kredia do te perdoret nga<span style="xfa-spacerun:yes"> </span><span style="font-weight:bold">Kredimarresi<span style="xfa-spacerun:yes"> </span></span>per</p></body>

               </exData>

            </value>

            <ui>

               <textEdit/>

            </ui>

            <margin leftInset="0.5mm" rightInset="0.5mm" topInset="0.5mm" bottomInset="0.5mm"/>

            <para vAlign="middle"/>

         </draw>

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

You can make some simple changes using span objects, so;

var spans = [];

spans.push({text:"Kredia do te perdoret nga "});

spans.push({text:"Kredimarresi", fontWeight:700});

spans.push({text:" per"});

var xHTML = util.spansToXML(spans);

Text1.value.exData.loadXML(xHTML, false, true);

Would give you something similar to your sample.

There are some other examples Adobe LiveCycle Designer Cookbooks by BR001: xmlToSpans but if you want to use one of the attributes that the span object does not support you could try using E4X (a XML extension for JavaScript) and there's a sample of that Adobe LiveCycle Designer Cookbooks by BR001: Adding values in a form to an email

Regards

Bruce

View solution in original post

3 Replies

Avatar

Level 7

I am not sure I understand the question. You want to update the <p> tag throughout the document similar to the way you would change CSS?

Avatar

Level 2

Almost right that way. I want to change <p> content and style through form JavaScript. Is it possible?

Avatar

Correct answer by
Level 10

Hi,

You can make some simple changes using span objects, so;

var spans = [];

spans.push({text:"Kredia do te perdoret nga "});

spans.push({text:"Kredimarresi", fontWeight:700});

spans.push({text:" per"});

var xHTML = util.spansToXML(spans);

Text1.value.exData.loadXML(xHTML, false, true);

Would give you something similar to your sample.

There are some other examples Adobe LiveCycle Designer Cookbooks by BR001: xmlToSpans but if you want to use one of the attributes that the span object does not support you could try using E4X (a XML extension for JavaScript) and there's a sample of that Adobe LiveCycle Designer Cookbooks by BR001: Adding values in a form to an email

Regards

Bruce