user2888402 user2888402 - 3 years ago 115
Javascript Question

show html output in textarea instead of HTML code

If I have a textarea including some HTML code, how can I write a JavaScript function to show the HTML output instead of HTML code itself, for example:

<textarea id="mytextarea">
<table border=1><tr><td>cellone</td>td>celltwo</td></tr></table
<input type=button onclick="HTMLoutput();"/>

//Code to show html output instead of html code in textarea

How can I do this? What is the suggested code to write inside the HTMLoutput()?

Answer Source

So to convert the the html code to a formated html you need to do:


here's an example that use div with contentEditable set to true.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download