Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

put in bold a part of a string

Avatar

Level 3

Hello

Is possible to put a part of a string in bold like :

var myText = "blablblla "+"<b>boldText</b>" +" reste of text";

Thanks

3 Replies

Avatar

Level 10

You can use richtext to display a string with bold characters.  Something like;

var richtext = <body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"><p>blablblla <span style="font-weight:bold">boldText</span> reste of text</p></body>;

TextField1.value.exData.loadXML(richtext.toXMLString(),true,false);

This assumes that TextField1 has a Field Format or rich text.

Avatar

Level 3

Thanks it works !

But i need to go at a new line. I tried <br> ou creation a new paragraphe, it dont works ! Only the first paragraphe is show !

exemple :

<p> my text</p>

<p> my text</p>

Avatar

Level 10

Try using;

TextField1.value.exData.loadXML(richtext.toXMLString(),false,false);

That is false in the second argument.  It seems that with this true then there are multiple root node and it only loads the first one.

Bruce