"Quote This User Function"

Discussion in 'JavaScript' started by LanceT, Apr 28, 2009.

  1. #1
    I need to know how to make a "Quote this User" function using script for my forum software.

    Basically on my forum underneath each username will be a "Quote This User" link and that link will insert what that user posted into the text area box underneath the post.
     
    LanceT, Apr 28, 2009 IP
  2. yz4now

    yz4now Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The best way would be to put what the user said in a <div></div> and assign an ID to that. Then when the users clicks "Quote This User" take the text from the DIV and transfer to the textarea.

    Something like this:

    
    <script type="text/javascript">
    function transfer(){
    var post = document.getElementById('user_post').innerHTML;
    document.getElemenyById('new_post').value = post;
    }
    </script>
    <div id="user_post">This is the users Post here</div>
    
    <input type="button" onclick="transfer();" value="Quote This User" />
    <textarea id="new_post"></textarea>
    
    Code (markup):
    Sorry for my sloppy code, it is just an example.
     
    yz4now, Apr 29, 2009 IP
  3. LanceT

    LanceT Peon

    Messages:
    279
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Btw I found the typo that you wrote elemeny instead of element.

    I'm also happening to use tinymce and your code only works when tinymce is disabled. Is there anyway to make it work WITH tinymce?
     
    LanceT, May 1, 2009 IP