Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Mar 2005
    Location
    United States
    Posts
    271
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Select All Content In Textbox

    Hey how can I make a button where if people clicked it, it selects all the text and copies it? Any help would be greatly appreciated.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,894
    Thanks
    202
    Thanked 2,528 Times in 2,506 Posts
    <Input tye="Button" value="Copy To Clipboard" onClick="document.form.textbox.select(); document.execCommand('Copy');">

    However, this only works in IE.

  • #3
    Regular Coder
    Join Date
    Mar 2005
    Location
    United States
    Posts
    271
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Okay then, but I saw a form that I could highlight all when using firefox, how can I do just highlight all?

  • #4
    Regular Coder
    Join Date
    Apr 2005
    Location
    austin, tx
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This goes in the <head> section...
    Code:
    <script language="Javascript">
    <!--
    function selectAll(theField) {
    var tempval=eval("document."+theField)
    tempval.focus()
    tempval.select()
    therange=tempval.createTextRange()
    therange.execCommand("Copy")
    }
    //-->
    </script>
    This is your <body>...
    Code:
    <form name="form">
      <a href="javascript:selectAll('form.area')">Select All</a><br>
      <textarea rows="7" cols="48" name="area">text to be selected</textarea></form>
    This code will SELECT ALL and COPY in I.E., but will not perform the COPY function in Firefox, the SELECT ALL still works in Firefox.
    Last edited by sftl99; 04-27-2005 at 08:28 PM.


  •  

    Posting Permissions

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