SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Feb 2006
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Insertion into textarea

    I have a button next to a textarea when they click that button it launchs another window. Now I need another button that will take a value (it will be an html code) close that window, and put that value in the textarea.

    Sort of like how when you click the link button in this wysiwyg editor it pops up a window that asks for some stuff and then inserts it here.

    Any help is much appreciated,
    thanks,
    Jordan

  2. #2
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found this using google: http://www.csie.ntu.edu.tw/~b88039/h...lib/caret.html , this will retrieve the cursor position in a textarea.

    If you don't know how to get the textarea value or fill it, here is some code:

    Code:
    <script language="JavaScript" type="text/javascript">
    function fill_it()
    {
      document.getElementById("mytext").value = 'blah <b>blah</b> blah';
    }
    
    function show_it()
    {
      document.getElementById("showtext").innerHTML = document.getElementById("mytext").value;
    }
    </script>
    
    <textarea id="mytext"></textarea>
    <br/><br/>
    <a href="#" onclick="fill_it()">Fill the text</a>
    <br/><br/>
    <a href="#" onclick="show_it()">Show the text</a>
    <br/><br/>
    <div id="showtext"></div>


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
  •