I have this while loop in PHP
<?php
while ($row = mysqli_fetch_assoc($getPosts)) {
$post_id = $row['post_id'];
echo "<td><a rel='$post_id' id='get_post_id'
onclick='active_del_modal()'>Delete</a></td>";
}
?>
In this loop, when we click on the "delete" link, the value of variable "$post_id" changes. I want to get the value of "$post_id" when it changes. I tried with this JS code
function active_del_modal() {
var x = document.getElementById("get_post_id").getAttribute("rel");
alert(x);
}
But it only gives me the last value of "$post_id". I want to get each value of "$post_id" when it changes and this value should be individual, not like this 23 46 545 545, etc. I don't want to use any framework like jQuery.