[mapguide-users] Javascript value to php

Jackie Ng jackie.ng at aecsystems.com.au
Wed Dec 5 17:34:37 EST 2007


Any one of these would work.

1 - Have a form that posts to your php script.

   eg. You have a form that looks like:

   <form id="frm" action="somescript.php" method="get">
        <input type="hidden" id="X" name="X" />
        <input type="hidden" id="Y" name="Y" />
   </form>

   Then somewhere in your javascript

   function OnPointDigitized(point) {
       document.getElementById("X").value = point.X;
       document.getElementById("Y").value = point.Y;
       document.getElementById("frm").submit();
   }

2 - Have a hidden iframe and you set the "src" attribute to your script,
append your X, Y values as parameters at the end.

   eg. myiframe.src = "somescript.php?X=" +  x + "&Y=" + y;

3 - Use XMLHttpRequest. Don't have an example here, there are tons of
examples available elsewhere.

Method 1 requires you to wait until the script has finished executing.
Methods 2 and 3 are usually asynchronous, and do not require you to wait.
Hope that helps.

- Jackie


mates wrote:
> 
> Hi. 
> How can i send a value from javasript to php?
> 
> I need the X and Y coordinates pass to a php script.The user click on the
> map and then the php script will work up this values. 
> 
> I use these functions 
> 
> function DigitizePoint() {
>     
> parent.parent.mapFrame.DigitizePoint(OnPointDigitized);
>       }
> 
> function OnPointDigitized(point) {
> ShowResults(point.X,point.Y);
>  } 
> 

-- 
View this message in context: http://www.nabble.com/Javascript-value-to-php-tf4952010s16610.html#a14182069
Sent from the MapGuide Users mailing list archive at Nabble.com.



More information about the mapguide-users mailing list