Change parts of text field to bold via JavaScript | Community
Skip to main content
May 31, 2021
Solved

Change parts of text field to bold via JavaScript

  • May 31, 2021
  • 3 replies
  • 9799 views

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!

Best answer by Kosta_Prokopiu1

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:

 

3 replies

Vijayalakshmi_S
Level 10
June 1, 2021
Pulkit_Jain_
Adobe Employee
Adobe Employee
June 2, 2021

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

sukram87Author
June 4, 2021

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?

Kosta_Prokopiu1
Adobe Employee
Kosta_Prokopiu1Adobe EmployeeAccepted solution
Adobe Employee
June 7, 2021

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:

 

January 17, 2023

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

 

April 7, 2024

Hello.

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

Thank you,

Ramona