Expand my Community achievements bar.

SOLVED

Change parts of text field to bold via JavaScript

Avatar

Level 1

Hi everyone

 

In Adobe Live Cycle Designer ES4, I have a text field named "TEXT" (option "Allow Multiple Lines" activated). It is binded to a string field of an ABAP structure.

I want to change certain parts of the text field to bold. They are already marked with "\b" for the starting point and "\b0" for the ending point.

How is that possible? I am not good with Javascript :(

TEXT.font.weight = "bold" works for me, the complete field changes to bold. But how can I change certain parts of the text field?

 

Thanks a lot in advance for any help!

1 Accepted Solution

Avatar

Correct answer by
Employee

Hi,

 

not so easy because you need to write the whole XHTML shebang into the exData section.

Make sure your TextField is of type Richtext!

Initialize event of the field:

 

var envelope = "<?xml version='1.0' encoding='UTF-8'?>" +

"<exData contentType='text/html' xmlns='http://www.xfa.org/schema/xfa-template/2.8/'" +

"><body xmlns='http://www.w3.org/1999/xhtml' xmlns:xfa='http://www.xfa.org/schema/xfa-data/1.0/' " +

"xfa:APIVersion='Acroform:2.7.0.0' xfa:spec='2.1'>" +

"<p> test <b>BOLD</b> test</p></body></exData>";

this.value.exData.loadXML(envelope,1,1)

 

result:

Kosta_Prokopiu1_0-1623053909651.png

 

View solution in original post

8 Replies

Avatar

Employee Advisor

@sukram87 

Here are some useful tricks if the text field is having Rich text data.

You can refer to the sample form shared with the blog for more insight on the implementation.

 

Hope this helps!

Avatar

Level 1

Hi PulkitJain

Thank you!

Unfortunately, it does not work. I know this article and tried it previously but without success:

sukram87_0-1622796739216.png

The field format is "Rich Text". What is wrong?

Avatar

Correct answer by
Employee

Hi,

 

not so easy because you need to write the whole XHTML shebang into the exData section.

Make sure your TextField is of type Richtext!

Initialize event of the field:

 

var envelope = "<?xml version='1.0' encoding='UTF-8'?>" +

"<exData contentType='text/html' xmlns='http://www.xfa.org/schema/xfa-template/2.8/'" +

"><body xmlns='http://www.w3.org/1999/xhtml' xmlns:xfa='http://www.xfa.org/schema/xfa-data/1.0/' " +

"xfa:APIVersion='Acroform:2.7.0.0' xfa:spec='2.1'>" +

"<p> test <b>BOLD</b> test</p></body></exData>";

this.value.exData.loadXML(envelope,1,1)

 

result:

Kosta_Prokopiu1_0-1623053909651.png

 

Avatar

Level 1

Hi Kosta,

thank you, that works fine But I have the problem that it doesnt accept free lines.

I can start a new line in my text field by adding <p> and </p>. But I cant add a complete free line.

How can I do that?

 

Thanks again!

Avatar

Employee

Did you try <br/> ? Use two that should give you a newline - and make your text field multi-line

Avatar

Level 1

Hi,

this is very nice post. But I would need go a bit deeper. I am not a coder in Javascript, so I am not sure how to achieve this.

When I use this example, it works fine. But I would like to have "<p> test <b>BOLD</b> test</p>" replaced by text field from binding in form. 

I am able to prepare variable and put there formatting tags, but I do not know, how to place it in form them.  Please, advise.

 

Thank you, 

david

 

Avatar

Level 1

Hello.

I have the same problem. Could you let me know if you found any solution?

Thank you,

Ramona