Search code examples
javascriptjqueryhtmlsimplemodal

Modal Display textarea contents not as string


I have a modal overlay window using simplemodal. I am trying to get it to display the contents of a text area. I can get it to display the contents, but only as a string. Say the user enters html or a picture into the text area such as:

<img src=mysite.png><br><font color=red>Hello!

I'd like it to actually render that for a preview, rather then just show the string and am unsure how to do that. I can pull the value and display it as a string, but not render it.

Below is the code I'm using: (CodeValue being the name of the textarea I'm pulling the value from).

<script>
jQuery(function ($) {
    // Load dialog on click
    $('#div-modal .basic').click(function (e) {
        $.modal(document.getElementById('CodeValue'));

        return false;
    });
});

</script>

Solution

  • If CodeValue is the ID of the textarea. add .value into it:

    $.modal(document.getElementById('CodeValue').value)