•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 391,558 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,767 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 3078 | Replies: 2
![]() |
•
•
Join Date: Sep 2007
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
I have asked this question earlier, but could not get a reply that
worked :-(
I have a single login_success.php file where I have written a function
I want to be able to store the following three properties of
PointsOfInterest. I am not sure if I need the command "return" as
well. All I want to do is store:
1) index i
2) .lat
3) .lng
into 3 PHP variables.
something like -
and then be able to use $lat, $lng to center the map to that point.
[inlinecode]
// Display the map, with some controls and set the initial location
var map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.setCenter(new GLatLng( <? $lat ?>, <? $lng ?>),15);
and use the index in a dynamic SQL query like this -
$result = mysql_query("SELECT cities.cityname, cities.citybuslink,
markers.information, markers.name, markers.address , markers.picture
FROM cities, markers where markerid = <? $index ?> AND markers.cityid =
cities.cityid ");
Do I really need to store the JS function return value into PHP variables or can I use the function IsWithinFixedGeofence()'s return value as a source everywhere else too ?
Something like
IsWithinFixedGeofence().lat
IswithinFixedGeofence().lng
and
IsWithinFixedGeofence().index
I heard AJAX would also work with something like this, but I am not
sure how to use it in this context..
I would be extremely grateful if you could help me with this
problem.
Best regards,
Amol
worked :-(
I have a single login_success.php file where I have written a function
IsWithinFixedGeofence(point)
{......
....
...
if ( distance <= MINIMUMDISTANCE )
{
return PointsOfInterest[i];
}
I want to be able to store the following three properties of
PointsOfInterest. I am not sure if I need the command "return" as
well. All I want to do is store:
1) index i
2) .lat
3) .lng
into 3 PHP variables.
something like -
IsWithinFixedGeofence(point)
{......
....
...
if ( distance <= MINIMUMDISTANCE )
{
<? $lat ?> = PointsOfInterest[i].lat;
<? $lng ?> = PointsOfInterest[i].lng;
<? $index ?> = i;
}
and then be able to use $lat, $lng to center the map to that point.
[inlinecode]
// Display the map, with some controls and set the initial location
var map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.setCenter(new GLatLng( <? $lat ?>, <? $lng ?>),15);
and use the index in a dynamic SQL query like this -
$result = mysql_query("SELECT cities.cityname, cities.citybuslink,
markers.information, markers.name, markers.address , markers.picture
FROM cities, markers where markerid = <? $index ?> AND markers.cityid =
cities.cityid ");
Do I really need to store the JS function return value into PHP variables or can I use the function IsWithinFixedGeofence()'s return value as a source everywhere else too ?
Something like
IsWithinFixedGeofence().lat
IswithinFixedGeofence().lng
and
IsWithinFixedGeofence().index
I heard AJAX would also work with something like this, but I am not
sure how to use it in this context..
I would be extremely grateful if you could help me with this
problem.
Best regards,
Amol
•
•
Join Date: May 2006
Location: New Jersey
Posts: 1,422
Reputation:
Rep Power: 5
Solved Threads: 34
Since JavaScript runs in the browser after PHP os processed on the server the only way to get this information to the server is to submit the data as either POST or GET data or use Ajax. But you can't affect the PHP used to render the page as it is long done processing the page by the time the JavaScript comes into play.
John Conde
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
Brainyminds | Merchant Account Services | I Love Code
IT'S HERE: Merchant Accounts 101 Everything you need to know about merchant accounts!
•
•
Join Date: Sep 2007
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Hi there,
Thanks very much for the reply.
I just figured out that instead of passing the javascript variables into PHP, I should store these into JS variables only.
if I use this code
It displays the correct value of lat from the database. in case here 56.4856.
I declared 3 global variables on the top of the document in order to assign them the values of latitude, longitude and index of the PointsOfInterest[i]
i.e.
var latitude =12 ; //12 is assigned just to test if this variable is being correctly assigned or not
var longitude;
var index ;
document.write(latitude);
The above command is displaying the value 12 instead of getting the value 56.4856 from PointsOfInterest[i].lat
Why is this so ??
Best regards
Thanks very much for the reply.
I just figured out that instead of passing the javascript variables into PHP, I should store these into JS variables only.
if I use this code
IsWithinGeofence(point)
{
....
...
if(distance <= minimiumdistance)
{
document.write(PointsOfInterest[i].lat);
}
}
It displays the correct value of lat from the database. in case here 56.4856.
I declared 3 global variables on the top of the document in order to assign them the values of latitude, longitude and index of the PointsOfInterest[i]
i.e.
var latitude =12 ; //12 is assigned just to test if this variable is being correctly assigned or not
var longitude;
var index ;
IsWithinGeofence(point)
{
....
...
if(distance <= minimiumdistance)
{
latitude = PointsOfInterest[i].lat;
longitude = PointsOfInterest[i].lng;
index = i;
}
}
document.write(latitude);
The above command is displaying the value 12 instead of getting the value 56.4856 from PointsOfInterest[i].lat
Why is this so ??
Best regards
Last edited by amol0010 : Sep 4th, 2007 at 7:36 am.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
- database connection(select ,insert query) within javascript function (JSP)
- Javascript Function Link (JavaScript / DHTML / AJAX)
- .net validation/javascript conflict (ASP.NET)
- HIDDEN Values <==Java Script Function Return value (JavaScript / DHTML / AJAX)
- Javascript Function to reload DOM Element? (JavaScript / DHTML / AJAX)
- Trying to get a javascript function to play a sound (JavaScript / DHTML / AJAX)
- Writing a javascript function (JavaScript / DHTML / AJAX)
- Can a function return 2 values? (C)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: How do you print part of a page in Javascript?
- Next Thread: call vb.exe from javascript



Linear Mode