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

159
Views
Las funciones Jquery Onclick no funcionarán en las otras páginas de la segunda tabla de datos

Tengo estas tablas de datos en mi php, pero las funciones jquery onclick solo funcionan correctamente en la primera página, pero no en las demás.

la vista de datos usando modal funciona bien y la eliminación de datos también, pero solo en la primera página

estos son mis botones

 <button type="button" id="<?php echo $row["Member_ID"]; ?>" class="btn btn-success btn-sm view_member_data"> <i class="bi bi-eye-fill"></i> </button> <button type="button" id="<?php echo $row["Member_ID"]; ?>" class="btn btn-danger btn-sm delete_member_data"> <i class="bi bi-trash-fill"></i> </button

el comando para ver y borrar datos:

 <script> $(document).ready(function() { $('.delete_member_data').click(function(e) { e.preventDefault(); var employee_id = $(this).attr("id"); Swal.fire({ title: 'Are you sure?', text: "You won't be able to revert this!", icon: 'warning', showCancelButton: true, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', confirmButtonText: 'Yes, delete it!' }).then((result) => { if (result.isConfirmed) { $.ajax({ url: "delete_members.php", method: "post", data: { employee_id: employee_id }, success: function(data) { Swal.fire( 'Deleted!', 'Member successfully deleted.', 'success' ).then((result) => { window.location.reload(true); }); } }); } }) }); }); </script> <script> $(document).ready(function() { $('.view_member_data').click(function() { var employee_id = $(this).attr("id"); $.ajax({ url: "view_member_data.php", method: "post", data: { employee_id: employee_id }, success: function(data) { $('#employee_detail').html(data); $('#dataModal').modal("show"); } }); }); }); </script>
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

He creado una variable global para employee_id, luego agrego employee_id al hacer clic en el botón.

Botones

 <button type="button" onclick="set_employee_id(<?php echo $row["Member_ID"]; ?>)" class="btn btn-success btn-sm view_member_data"> <i class="bi bi-eye-fill"></i> </button> <button type="button" onclick="set_employee_id(<?php echo $row["Member_ID"]; ?>)" class="btn btn-danger btn-sm delete_member_data"> <i class="bi bi-trash-fill"></i> </button>

JS

 <script> var employee_id; function set_employee_id(id){ employee_id = id; } $(document).ready(function() { $('.delete_member_data').click(function(e) { e.preventDefault(); Swal.fire({ title: 'Are you sure?', text: "You won't be able to revert this!", icon: 'warning', showCancelButton: true, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', confirmButtonText: 'Yes, delete it!' }).then((result) => { if (result.isConfirmed) { $.ajax({ url: "delete_members.php", method: "post", data: { employee_id: employee_id }, success: function(data) { Swal.fire( 'Deleted!', 'Member successfully deleted.', 'success' ).then((result) => { window.location.reload(true); }); } }); } }) }); }); $(document).ready(function() { $('.view_member_data').click(function() { $.ajax({ url: "view_member_data.php", method: "post", data: { employee_id: employee_id }, success: function(data) { $('#employee_detail').html(data); $('#dataModal').modal("show"); } }); }); }); </script>
about 4 years ago · Santiago Trujillo 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!