473,395 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Cut & Paste

I use these two functions for Copy & Paste with buttons in some text area
into a form:

<SCRIPT LANGUAGE="Javascript">

function copy(area){
var temp = eval("document." + area);
aa=temp;
window.clipboardData.setData('Text',aa);
}

function paste(area2){
var temp2 = eval("document." + area2);
bb=window.clipboardData.getData('Text');
temp2 = bb;
}
</SCRIPT>
</head>
If i call the Copy function (dinamically with php) with a parameter like:
form1.text1.value it works fine, but with the Paste function doesn't work.
I think the problem is in the evaluate statement of the parameter area2.

Anyone can help me ?? Thanks

Simone
Jul 23 '05 #1
3 4333
Simo wrote on 28 apr 2004 in comp.lang.javascript:
<SCRIPT LANGUAGE="Javascript">

function copy(area){
var temp = eval("document." + area);
aa=temp;
window.clipboardData.setData('Text',aa);
}

function paste(area2){
var temp2 = eval("document." + area2);
bb=window.clipboardData.getData('Text');
temp2 = bb;
}
</SCRIPT>


Try this:

<div id=from>qwerty</div>
===========================
<div id=to>asdfg</div>

<script type="text/javascript">

function copy(area){
var temp = document.getElementById(area);
window.clipboardData.setData('Text',temp.innerHTML );
}

function paste(area){
var temp = document.getElementById(area);
temp.innerHTML = window.clipboardData.getData('Text');
}

copy("from")
paste("to")
</script>

Tested IE6

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #2
Simo wrote:
I use these two functions for Copy & Paste with buttons in some text area
into a form:

<SCRIPT LANGUAGE="Javascript">

function copy(area){
var temp = eval("document." + area);
aa=temp;
window.clipboardData.setData('Text',aa);
}

function paste(area2){
var temp2 = eval("document." + area2);
bb=window.clipboardData.getData('Text');
temp2 = bb;
}
</SCRIPT>
</head>
If i call the Copy function (dinamically with php) with a parameter like:
form1.text1.value it works fine, but with the Paste function doesn't work.
I think the problem is in the evaluate statement of the parameter area2.

Anyone can help me ?? Thanks

Simone


Wow... where do I start?

1. Do not use LANGUAGE. Instead, use TYPE
2. Do not use eval(). There are always better ways to do it
3. Dont make so many temp variables. It makes it hard to read
4. clipboardData only works in IE 5+. I dont know if anything like this
exists in other browsers.

Try something more like this. Of course, modify it for a better set of
what you need, but this should give you a good start.

-- Brian

<HTML>
<HEAD>
<SCRIPT type="text/javascript">

function copy(source){
window.clipboardData.setData("Text",
document.getElementById(source).value);
}

function paste(dest){
document.getElementById(dest).value =
window.clipboardData.getData("Text");
}

function CopyAndPaste( from, to )
{
copy(from); paste(to);
}

</SCRIPT>
</HEAD>

<BODY>
<FORM action="submit.asp">
<INPUT TYPE=text name=text1>Text 1<BR>
<INPUT TYPE=text name=text2>Text 2<BR>
</FORM>

<BUTTON onClick="CopyAndPaste('text1', 'text2')">
Copy and Paste
</BUTTON>

</BODY>
</HTML>

Jul 23 '05 #3
Brian Genisio wrote:

4. clipboardData only works in IE 5+. I dont know if anything like this
exists in other browsers.


IE 5+ Windows!
Mick.

Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: tabonni | last post by:
Hello All I am creating an ASP page. There are a list of filename and checkbox next to it. When user checked all the documents they want and click ADD TO CLIPBOARD button. All filepaths will be...
7
by: William Gill | last post by:
Is there a simple way to cut and paste from a tkinter text widget to an entry widget? I know I could create a mouse button event that triggers a popup (message widget) prompting for cut/paste in...
1
by: Tomomichi Amano | last post by:
Hello. I was wondering how to paste-copy-cut-delete at a SELECTED SPOT in a textBox. Thanks in advance.
6
by: NuB | last post by:
I have a winform and a menu on the form, It allows the users to copy and paste text from text boxes. I never had to do this before, how can I copy and paste text from one box to another?
26
by: Robert Baer | last post by:
The following passes the test as valid, and the mouseover for the six indicated areas also work. I need various areas to link to another page, including the six mentioned. However either the MAP...
14
by: Arne | last post by:
A lot of Firefox users I know, says they have problems with validation where the ampersand sign has to be written as &amp; to be valid. I don't have Firefox my self and don't wont to install it only...
28
by: entfred | last post by:
I have the following line of html: &nbsp;&nbsp1234&nbsp;&nbsp;&nbsp;&nbsp;&nbspabc&nbsp;&nbsp;&nbspyow In Internet Explorer 6.0, the columns look ok using the above html: 1234 abcd ...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
6
by: roopashree | last post by:
hi, currently I am able to cut,copy and paste images for only one image. Suppose I have 4 images-then I should group all the images so that I can cut/copy all 4 images and paste them. How...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.