A.R A.R - 1 year ago 112
Javascript Question

onclick event alert value of variable php mysql

I want to alert id when user click on the button.But i am getting the same id on every button whereas when i inspect element it have different values. This is a part of my code

Fetching code:

$sql="select * from `table_name`";
$result=mysqli_query($con,$sql) or die(mysqli_error($con));
<button type="button" class="btn btn-danger" id="block" onclick="blockit(this.value);" value="<?php echo $row['id'];?>">Block</button>


function blockit()
var a=document.getElementById("block").value;

Answer Source

pass the parametre in your function

function blockit(val)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download