I want to capture the X:Y values indicating where the user clicked on the animated image by checking the php $_POST array. The problem is that while I can get the input submission information on the static image, I can't seem to get any values from the animated image.
Here are the complete HTML pages and forms that demonstrate this behavior:
<!doctype html> <html> <head> <meta charset="utf-8"> <title>Gunfighter Testing Page</title> <style> div { width:24px; height:24px; position:relative; -webkit-animation:glide 1s ease-in-out alternate infinite; } @-webkit-keyframes glide { from { left:-400px; top:0px; } to { left:400px; top:0px; } } </style> </head> <body> <center> <form method="post"> <input type="image" name="Staredown" value="Staredown" alt="Staredown" src="https://i.imgur.com/sQwX4Qg.png"> <input type="image" name="Gesture" value="Gesture" alt="Gesture" src="https://i.imgur.com/0iJnH5Q.png"><br> <div><input type="image" name="Shoot" value="Shoot" alt="Shoot" src="https://i.imgur.com/i9oV2j3.png"></div> ; </form> </center> </body>
Here is some php that checks form (button) submission and displays the coordinates within the clicked image:
<?php //var_dump($_POST); echo "Form (button click) results (a pefect score is x=32 and y=32: <br>\n"; echo "<p>\n"; if ((isset($_POST["Staredown_x"])) || (isset($_POST["Gesture_x"])) || (isset($_POST["Shoot_x_x"]))){ switch(true){ case (isset($_POST["Staredown_x"])): echo "Staredown click coords=> break; case (isset($_POST["Gesture_x"])): echo "Gesture click coords=> break; case (isset($_POST["Shoot_x"])): echo "Shoot click coords=> break; } } else { echo "Score will be displayed upon clicking on a button.<br>\n"; } ?>
Why can I get the click coordinates in the clicked image (if they are static), but can't get the animated image to behave the same way? The animated image does not populate $_POST["Shoot_x"] with the coordinates of the click (or register in any other way that I can seem to collect in php).
This example will work as written if (unlike me) you pay attention to typing and checking $_POST["imagename_x"] instead of checking $_POST["imagename_x_x"] Form work>"] Just like I did.