TeamDesk Knowledge Base & Support

   Home      FAQ      Forum      Idea Exchange      Ask a Question      My Stuff      Help   
  
COPY BUTTON
Hi,

Is there any easy way to have a 'Copy to Clipboard' button appear adjacent to certain fields on a TD screen? There are many times when one needs to copy the contents of a field to the clipboard and paste it into an email or spreadsheet. A button would be much easier than highlighting the field and right-clicking to copy...

Lawrence
ID
2090
Category
Customization
Author

Lawrence Bricknell
Date Created
11/8/2024 11:53:13 AM
Date Updated
11/8/2024 1:56:07 PM
Comments
cooper collier  11/8/2024 1:24:00 PM
I have done this using an xhtml column. So you would need to make a new xhtml for each field. Put the content of the field into the xhtml, then make an html button for the copy.
cooper collier  11/8/2024 1:56:07 PM
this untested code should work, you need to put the javascript into a DBscript file in resources
then you can call it from the button. You can easily change how the button looks, make it a small copy icon.

<div style="background-color:yellow; color:navy;">
<p><%=[your column name]%></p>
<button onclick="copyToClipboard('<%=[your column name]%>')" style="margin-top: 10px; background-color: navy; color: white; padding: 10px 20px; border: none; cursor: pointer;">Copy to clipboard</button>
</div>

<script type="text/javascript">
function copyToClipboard(text) {
// You can implement your copy to clipboard function here
// as it requires JavaScript. The code to copy text to the clipboard
// varies depending on the browser and environment.
// Here's a simple example using document.execCommand('copy'):

const copyText = document.createElement('textarea');
copyText.style.position = 'absolute';
copyText.style.left = '-9999px';
copyText.style.top = '0';
copyText.value = text;
document.body.appendChild(copyText);
copyText.select();
document.execCommand('copy');
document.body.removeChild(copyText);
}
</script>
Feedback
Back to Search Results