Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

156
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda