Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

157
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda