SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Mar 2011
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Execute dynamic HTML/JavaScript

    Hi,

    I'd like to create a textarea and a division so that whatever embed code you put in the textarea it gets executed on the division in real-time.

    Your kind help is greatly appreciated!
    JavaScript newbie

  2. #2
    SitePoint Member
    Join Date
    Mar 2011
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After hours searching and trying different approaches I came up to the following simple code:

    Code:
    <script type="text/javascript">
    var X = " HTML or JavaScript "
    window.onload=function()
    {
    document.getElementById("result").innerHTML = document.getElementById("input").value;
    }
    </script>
    
    <textarea id="input" cols="35" rows="7"> X </textarea>
    
    <div id="result"></div>
    All I need is using eval function to get the whole code (HTML or JavaScript) as one variable. I wonder if someone can help me with this as I'm badly stuck!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •