Search code examples
javascripthtmlcssstruts2stylesheet

struts2 textarea add style to only one word


I have struts 2 <s:textarea> setting value dynamically using JavaScript. In my JavaScript I am constructing a single String using an array of Strings, in that I want to show some dynamic feature to the updated array index.

How to add style to the specific array index before constructing single string. So that when I set the constructed String as,

strarray[2]=strarray[2].bold();
styleString=strarray.join('|');
document.forms[0]["updatedtxtArea"].value=styleString;

it will bold the single array index only, In my Textarea, it shows like ...welcome to <b>value of (strarray[2])</b> I want to see the bold result but it shows html stuff itself?? I want to replace the <b> to real feel like value of(strarray[2]). How to make this true? is there any alternate way... anyway I want to do it. please....


Solution

  • textareas only accept string input, you can't add styling like you would in HTML.

    A solution is to switch to contenteditable but that's quite a can of worms in and of itself.