472,144 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

how to cut/paste & copy/paste images using javascript

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 can I do this?

I have used an array to store all the images.

If you have any code for this please send it to me or a website link.
Else logic as to how am I to Proceed.


waiting for the reply.
Jun 1 '07 #1
6 2924
acoder
16,027 Expert Mod 8TB
Well, if you can do it for one image, just loop through the array for all images:
Expand|Select|Wrap|Line Numbers
  1. for(i = 0; i < imgArray.length; i++) {
  2.  img = imgArray[i];
  3.  //whatever you want to do with the image
  4. }
Jun 1 '07 #2
hi,

I am new to javascript.How to copy and paste 2 or more images using javascript?


Please send the code or the link. It will be helpful.
Jun 4 '07 #3
hi,

I am new to javascript? I need a code to cut and paste 4 images using javascript.


please send me the code or the link for this.
Jun 4 '07 #4
acoder
16,027 Expert Mod 8TB
Threads merged. You've already started a thread on this, please do not double post.

Have you tried what I posted earlier? Post some code that you've managed so far.
Jun 4 '07 #5
Threads merged. You've already started a thread on this, please do not double post.

Have you tried what I posted earlier? Post some code that you've managed so far.

the code which I have tried to delete one image is given below:
I have called the destroy(); function using keydown event in a switch statement.
sh is the image object.

case 46: //delete code-ascii value of delete key
destroy();
destroyall();
break;
function destroy()
{
sh.parentNode.removeChild(sh);
}

function destroyall()
{
alert('destroyall');
if(selectall) //var selectall=true;
{
alert('entered if');
for(var i=1;i<shapestore.length;i++) //shapestore is an array which holds all images
{ //alert(shapestore.length);
alert('enter for');
//shapeid is the id of a particular image
clipboard=sh.shapeid;
//img=sh..shapestore[i];
sh.parentNode.removeChild(clipboard);

//delete shapestore[i];
// var rm=sh.parentNode.removeChild(sh);
// delete rm.id;
}
}
}
Jun 5 '07 #6
sumittyagi
202 Expert 100+
the code which I have tried to delete one image is given below:
I have called the destroy(); function using keydown event in a switch statement.
sh is the image object.

case 46: //delete code-ascii value of delete key
destroy();
destroyall();
break;
function destroy()
{
sh.parentNode.removeChild(sh);
}

function destroyall()
{
alert('destroyall');
if(selectall) //var selectall=true;
{
alert('entered if');
for(var i=1;i<shapestore.length;i++) //shapestore is an array which holds all images
{ //alert(shapestore.length);
alert('enter for');
//shapeid is the id of a particular image
clipboard=sh.shapeid;
//img=sh..shapestore[i];
sh.parentNode.removeChild(clipboard);

//delete shapestore[i];
// var rm=sh.parentNode.removeChild(sh);
// delete rm.id;
}
}
}

Here you have used the removeChild method.

Now for adding elements you have appendChild or, insertBefore methods.

Just you would have to give ids to the element containers, so that when you want to paste them you can get those elements.

Or if you want to paste them by mouse events, then you could get the ev.getSource (or something similar to this, I don't exactly remember)
Jun 5 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Tomomichi Amano | last post: by
7 posts views Thread by lgbjr | last post: by
3 posts views Thread by Mateusz Rajca | last post: by
reply views Thread by Saiars | last post: by

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.