Skip to main content
May 31, 2021 3:37 PM UTC
Solved

Change parts of text field to bold via JavaScript

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!

Kosta_Prokopiu1
Kosta_Prokopiu1Accepted solution
Adobe Employee
Jun 7, 2021 8:16 AM UTC

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:

 

9 replies

Vijayalakshmi_S
Level 10
Jun 1, 2021 2:31 PM UTC
Pulkit_Jain_
Adobe Employee
Adobe Employee
Jun 2, 2021 10:18 AM UTC

@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!

Translate
sukram87Author
Jun 4, 2021 8:51 AM UTC

Hi PulkitJain

Thank you!

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

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

Translate
Kosta_Prokopiu1
Adobe Employee
Kosta_Prokopiu1Adobe EmployeeAccepted solution
Adobe Employee
Jun 7, 2021 8:16 AM UTC

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:

 

Translate
sukram87Author
Jun 8, 2021 4:29 PM UTC

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!

Translate