I want to make an img html tag as a button that sends a value php to a function js and then insert it into an array, if you could help me I thank you infinitely
php
while($row = mysqli_fetch_array($result)){
$cartaNombre = $row["Carta"];
echo "<img src='$cartaNombre' name='$cartaNombre' alt='no se encuentra' width='7%' class='cartas' onclick='this.disabled = true; valor(this)'>";
}
js
var ESEAadn = [];
function valor(element) {
alert(element.getAttribute("name"));
var value = element.getAttribute("name");
ESEAadn.push(value);}
this is the code