SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Guru
    Join Date
    Sep 2001
    Location
    Vancouver
    Posts
    809
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking Copy and Select All Buttons

    Hi,

    I need help with something for my forms. Would someone be kind enough to tell me how to create two buttons under my text form, which do the following. The first one selects everything in that particular input field, and the other one copies everything in that field.

    I need this for my content management system. It creates a bunch of HTML code, which I have to select everytime and copy and paste it. It would be very useful to have two buttons do that.

    I've seen this on other sites if that helps. Thank you for your help!

  2. #2
    That's Right. notepad_coder's Avatar
    Join Date
    Apr 2002
    Location
    Colorado
    Posts
    835
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why do you have to copy and paste it everytime?

    The only way I know of is click inside the textarea, hit Ctrl+A, Ctrl+C, then Ctrl+V
    - the lid is off the maple syrup again!

  3. #3
    SitePoint Evangelist
    Join Date
    Jan 2002
    Posts
    420
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <input type="button" onClick="document.formName.test.select()" value="Select">
    <textarea rows="10" cols="20" name="test"></textarea>
    sorry not much time to explain right now but do you get what I mean?
    Wavelan

  4. #4
    SitePoint Wizard
    Join Date
    Oct 2001
    Location
    Tucson, Arizona
    Posts
    1,858
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  5. #5
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:

    <script>
    function 
    selected(formseltxt)
    {
        if (
    form==null || form=='')
        {
            
    alert('form not entered');
        }
        else
        {
            
    = eval('document.' form '.' seltxt);
            
    x.select();
        }

    }
    </script>



    <form name="form1">
    <textarea rows="10" cols="20" name="test" id="test"></textarea>
    <input type="button" onClick="selected()" name="none" id="none" value="Select">
    </form> 

  6. #6
    SitePoint Guru
    Join Date
    Sep 2001
    Location
    Vancouver
    Posts
    809
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you all for your help!!


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
  •