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

182
Views
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 answers
Answer question

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 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!