gar onn Posted November 25, 2009 Share Posted November 25, 2009 I would like to use an input type image to get the coords clicked (progressed with PHP)<input name="action" id="action" type="image" src="url/to.img"> but... I want to send them with AJAX...anyone some ideas? Link to comment Share on other sites More sharing options...
justsomeguy Posted November 25, 2009 Share Posted November 25, 2009 Put an onclick handler on the image, or an onsubmit handler on the form (the onsubmit would probably be better), and in the handler have it write out the event information to the Firebug console and see if the coordinates are included. If it's the onclick handler, you'll probably find the coordinates somewhere in the event object. If it's the onsubmit handler, it might actually create new hidden form elements that have the coordinates. So in the handler send everything you can to the Firebug console, send the event object, any parameters to the handler, the form element, etc. e.g.: function submit_handler(a, b, c, d){ console.log(a); console.log(b); console.log(c); console.log(d); console.log(window.event); console.log(document.getElementById('form_id'));} In that example, in some browsers the "a" parameter will be the event object, and in others it will be window.event. Link to comment Share on other sites More sharing options...
gar onn Posted November 25, 2009 Author Share Posted November 25, 2009 tnx,thant was great information but not what I was looking for, I think I'm going to use an form with an invisible target (iframe) with an PHP code wish sets a cookie Link to comment Share on other sites More sharing options...
justsomeguy Posted November 25, 2009 Share Posted November 25, 2009 I forgot about something else, when you have a click event I believe that the event handler always includes the coordinates where the event happened, so you should be able to have an onclick handler on any element and get the coordinates from the event object. Link to comment Share on other sites More sharing options...
gar onn Posted November 26, 2009 Author Share Posted November 26, 2009 But that gives the coords from tthe windows topleft corner.I 've used this: <form action='Jfpasout.php' name="action" target="dmp"><input name="coords" id="coords"><br/><input name="action" id="post" type="image" src="testzone.php?img" width="*"> <input name="map_s" value="action"></form><iframe style="display: none;" name="dmp" src="Jfpasout.php"></iframe> and the PHP of Jfpasout.php function mapcoordsname($name){$eline="\$value=\$_REQUEST['".$name."_x'].\"|\".\$_REQUEST['".$name."_y'];";eval($eline);return $value;} $mapname=$_REQUEST['map_s']; $value=mapcoordsname($mapname); echo "<script>window.parent.document.".$mapname.".coords.value='$value'</script>"; and that works fine but tnx Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.