Get innerHTML from input

How can I get the innerHTML of an Input Field/Text Area?

I create a post where a preview of the text area input is shown in a text component with HTML enabled so that line breaks are recognised and when posting to server the string contains html markup too.

I’ve tried the following:

Text Area > On Change Action > Save Data to App State:

return {{ui.textarea.value.innerHTML}};
OR
return {{ui.textarea.innerHTML}};

Thank you, kindly assist.

Hi @Mancha!

You can get the value only: {{ui.textarea.value}}

To display the text from Text area in a Text component with the line breaks reconized, you need to process the Text area value replacing all the '\n' elements (meaning a line break) with '<br>' (moving to a new line in HTML), and use this value in the Text including withHtml in it.

Here’s an example of how you can process it:

const value = {{ui.textarea.value}};
return value.replaceAll('\n', '<br>');

Hope it helps!

1 Like