Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

copying to clipboard

 
Ramesh Patil
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a jsp application where i write data into a html page as it is using <table> . This data is not in a text area or text box. Below is the code.

<tr bgcolor="#FFFFFF">
<div align="Left">
<font face='verdana' size="-1">
<b>
1000 , ABCD ,
</b>
</font>
</div>
</tr>
<tr bgcolor="#FFFFFF">
<div align="Left">
<font face='verdana' size="-1">
<b>
2000 , ABCDE ,
</b>
</font>
</div>
</tr>

The output is shown below.

1000 , ABCD ,
2000 , ABCDE ,

I need to have a button which can select all the above data and copy it to a clipboard which can be pasted in a text file or excel file.

I am not able to select all the data but I am able to copy selected data into a clipboard.
Please help.
Thank you.
Ramesh
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You try this?

Eric
 
Ramesh Patil
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Eric. I looked up in google and
this is what I got. This works even if we aren't copying a textarea.



<SPAN ID = "copytext"<
text..........
</SPAN<


<TEXTAREA ID="holdtext" STYLE="display:none;"<
</TEXTAREA<
<BUTTON onCLLL="ClipBoard();"<Copy to Clipboard</BUTTON<




function Clip()
{
holdtext.innerText = copytext.innerText;
Copied = holdtext.createTextRange();
Copied.execCommand("RemoveFormat");
Copied.execCommand("Copy");
}

<BUTTON onCLL="Clip();"<Copy to Clipboard
</BUTTON<
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic