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

192
Visualizações
copy the value of a hidden field from a button

I am trying to copy the value of a hidden text field from another button. At the moment I'm trying to simply show it with an alert when I click on the button but it doesn't work. What am I doing wrong ?

php:

echo "<p id='campoCopiar' class='btn btn-warning btn-lg paginasTotales'>Páginas totales: <b>" . $paginasTotales . "</b></p>";
echo "<input id='oculto' name='oculto' type='hidden' value='" . $paginasTotales . "'>";

js:

document.querySelector("#campoCopiar").addEventListener("click", function(){
    var oculto = document.querySelector("#oculto").value;
    alert(oculto);
});

The variable is defined because one line above I have another code where it shows it and it works correctly.

The call to the js file I have it at the bottom just before the closing tag of the body

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The $paginasTotales variable isn't declared anywhere in your code, it seems like it's empty. Maybe that's why?

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