Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

154
Views
Javascript copy text with Gravity View tables?

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".

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!