I am using the following script to copy text:
function copyToClipBoards() {
var content = document.getElementById('oldone');
content.select();
document.execCommand('copy');
alert("Copied!");
}
The script works. Here's the problem... I am using a plugin called GravityView to show the information. They have a table with each row. The text box is filling in correctly under each row BUT the copy text action is only copying the first box and not the box I'm currently selecting. Is there any way to edit this code differently?
Example: https://barrelrace.com/0new-prod-dash/
Look at the first table of "Upcoming Races".
Assuming your table has an id of oldone you could try:
var content = document.getElementById("oldone");
for (var i = 0; i < content.rows.length; i++) {
for (var j = 0; j < content.rows[i].cells.length; j++)
content.rows[i].cells[j].onclick = function () {
getval(this);
};
}
function getval(cell_text) {
navigator.clipboard.writeText(cell_text.innerHTML);
alert("Copied");
}
Here's a codepen example: https://codepen.io/rochekaid/pen/rNzoPNJ?editors=1010