0

I am trying to get the ID of each a LISTED data fetched from MySql to UPDATE using a bootstrap model when update button clicks from the same page.

Passed id to the href and converting that to a javascript variable. And using that variable in PHP.

<td colspan="2"><a class="btn btn-danger updatebtn" name="updateuser" href="<?php echo $row['ID']; ?>" data-toggle="modal" data-target="#updateuser">Update</a></td>

$(document).ready(function(){
    $('.updatebtn').click(function() {
      var modelId = $(this).attr('href');
    });
  });

<?php $id1 = "<script>document.write(modelId)</script>"; ?>
Alvin R
  • 29
  • 7
  • what is not `working` ? did you got any `error` ? – Swati Jun 23 '19 at 12:56
  • There is no error, but no value is getting for the variable – Alvin R Jun 23 '19 at 13:15
  • You can send your `modelId`using ajax and get that variable in your php page for further processing , Also i suggest you to read [this](https://stackoverflow.com/questions/1917576/how-to-pass-javascript-variables-to-php) – Swati Jun 23 '19 at 13:36

0 Answers0