javascript - Need idea to use variable JS outside and use button to send data -


this script save id of row clicked. : "if click on buttonmodif change url , send variable number (which id of row) url (and next page) . i'm not sure how it.

i save variable number outside script , when click on buttonmodif send variable url.

thank answer!

html file :

<div id="page-wrapper" style=" padding-left: 20px">     <form method="post" name="employes1" action="employes.php">         <div class="container-fluid">             <div class="row">                 <div class=" text-center">                     <button type="button"                             class="btn btn-default"><?php echo '<a href="employesajout.php" > ajouter un employé </a>'; ?></button>                       <button type="submit" name="buttonmodif" id="modifon"> mofidier informations</button>                     <button type="submit" class="btn btn-default">supprimer employé</button>                     <button type="button" class="btn btn-default">créer un contrat de travail</button>                 </div>              </div>             <div class="row table-responsive">                  <table class="table table-bordered table-hover" id="mytable">                     <thead class="-inverse">                      <?php                     $rep = $bdd->prepare('select * employee');                     $rep->execute();                     $resultat = $rep->fetchall();                     ?>                       <tr>                         <th>#</th>                         <th>nom</th>                         <th>prénom</th>                         <th>résidence</th>                         <th>nas</th>                         <th>date d'entré</th>                         <th>heure /semaine</th>                         <th>salaire brute</th>                         <th>salaire net</th>                         <th>vacance (s)</th>                         <th>email</th>                       </tr>                      </thead>                     <tbody>                      <?php foreach ($resultat $row) {                          echo "                   <tr class ='clickable-row'>                     <td>$row[0]</td>                     <td>$row[1]</td>                     <td>$row[2]</td>                     <td>$row[3]</td>                     <td>$row[4]</td>                     <td>$row[5]</td>                     <td>$row[6]</td>                     <td>$row[7]</td>                     <td>$row[8]</td>                     <td>$row[9]</td>                     <td>$row[10]</td>                 </tr>";                      };                      ?>                      <script>                          $(document).ready(function ($) {                              $(".clickable-row").click(function () {                                  var number = parseint($(this).closest('tr').children().eq(0).text());                                 console.log(number);                              });                               // active click hilight                             $('td').click(function () {                                 $('tr').removeclass('active');                                 $(this).parent().addclass('active');                             });                           });                      </script>                       </tbody>                 </table>              </div>          </div>     </form>  </div> 

declare variable outside click function. bind click handler on buttonmodif button uses variable. can add type="hidden" input form, , put value there.

$(document.ready(function() {     var number;      $(".clickable-row").click(function() {         number = parseint($(this).closest('tr').children().eq(0).text());         console.log(number);     });      $("#modifon").click(function() {         $("#hiddenfield").val(number);     }); }); 

Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -