Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 4.00 average.
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-27-2005, 06:44 AM   PM User | #1
DigitalBliss
Regular Coder

 
Join Date: Mar 2005
Location: United States
Posts: 271
Thanks: 0
Thanked 0 Times in 0 Posts
DigitalBliss is an unknown quantity at this point
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.
__________________
-the core- -the structure-
DigitalBliss is offline   Reply With Quote
Old 04-27-2005, 07:07 AM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,043
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
<Input tye="Button" value="Copy To Clipboard" onClick="document.form.textbox.select(); document.execCommand('Copy');">

However, this only works in IE.
Philip M is offline   Reply With Quote
Old 04-27-2005, 06:02 PM   PM User | #3
DigitalBliss
Regular Coder

 
Join Date: Mar 2005
Location: United States
Posts: 271
Thanks: 0
Thanked 0 Times in 0 Posts
DigitalBliss is an unknown quantity at this point
Okay then, but I saw a form that I could highlight all when using firefox, how can I do just highlight all?
__________________
-the core- -the structure-
DigitalBliss is offline   Reply With Quote
Old 04-27-2005, 08:04 PM   PM User | #4
sftl99
Regular Coder

 
Join Date: Apr 2005
Location: austin, tx
Posts: 148
Thanks: 0
Thanked 0 Times in 0 Posts
sftl99 is an unknown quantity at this point
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..
sftl99 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:15 AM.


Advertisement
Log in to turn off these ads.