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.
SOLVED

How to Italicize text in a switch case raw text value

Avatar

Level 2

Can anyone tell me how to italicize partial text in a switch/case statement of raw text (in the example, the text in uppercase)?

 

switch (this.rawValue){

    case "0":

        MyText.rawValue = "Text example one"

        break;

 

    case "1":

        MyText.rawValue = "Text example two, THIS TEXT TO ITALICS."

        break;

}

1 Accepted Solution

Avatar

Correct answer by
Level 2

I solved the issue by creating multiple Text+ boxes with pre-filled text including text that is italicized, then made its presence "Hidden from layout".

When user selects the appropriate text box, it makes it "visible" and makes the others "hidden".

View solution in original post

4 Replies

Avatar

Community Advisor

Hi,

 

We can use Rich Text and restrict the plugins to only have B/I/U, so we can select a specific text to italic or if you want to achieve it only by Raw Html, you can try the below options.

 

1) Adding italic tags in the raw html text area and in sightly using context @html will display the text in italic

 

Screen Shot 2022-02-08 at 11.53.36 AM.png

 

  Screen Shot 2022-02-08 at 11.53.43 AM.png

Or add some special characters around the text which needs to be italic and replace that with <i> in java 

Or In java we can also check the character is caps and add the italic tag

Avatar

Level 2

But to change it using javascript, if I put <i></i> tags around the text, they show in the text field as tags.

myText.rawValue = "Please note this <i>italicized text</i>"

 

Displays as 
Please note this <i>italicized text</i>

 

Text is being displayed programmatically depending on the selection from a dropdown list, it's not text being entered by user.

Avatar

Level 6

If you are trying this from Javascript you can tey using Jquery functions available. Check this link out: https://stackoverflow.com/questions/20267775/jquery-inserted-html-is-rendered-as-a-raw-text 

Avatar

Correct answer by
Level 2

I solved the issue by creating multiple Text+ boxes with pre-filled text including text that is italicized, then made its presence "Hidden from layout".

When user selects the appropriate text box, it makes it "visible" and makes the others "hidden".