Daniish
asked on
How to call a PHP script using a Javascript onClick event?
Hello,
Having see this tutorial on calling a PHP script from a Javascript onClick:
http://www.peoplecnc.com/java_php.html
I would like to know how i can call a php script called 'poi_info.php' from the attached Javascript snippet in the place of the text:
"This is where i want a random image, title & date"
Mnay thanks
Having see this tutorial on calling a PHP script from a Javascript onClick:
http://www.peoplecnc.com/java_php.html
I would like to know how i can call a php script called 'poi_info.php' from the attached Javascript snippet in the place of the text:
"This is where i want a random image, title & date"
Mnay thanks
GEvent.addListener(marker, "click", function() {
map.setCenter(marker.getPoint(),maxZoom,G_SATELLITE_MAP);
marker.openInfoWindowHtml("<div style='padding:5px'>This is where i want a random image, title & date</div>",{maxContent: html, maxTitle: infotitle, noCloseOnClick: true});
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You mean like this:
var title = marker.getElementsByTagNam e("title") .firstChil d.nodeValu e;
var date = marker.getElementsByTagNam e("date"). firstChild .nodeValue ;
document.getElementById("[ iw]").inne rHTML = title+"<br>"+date;
..
function doHttpRequest() { // This function does the AJAX request
http.open("GET", "poi_info.php", true);
http.onreadystatechange = getHttpRes;
http.send(null);
}
.. where this is the div i'm trying to update:
marker.openInfoWindowHtml( "<div id='iw' style='padding:5px'>This is where i want a random image, title & date</div>",{maxContent: html, maxTitle: infotitle, noCloseOnClick: true});
var title = marker.getElementsByTagNam
var date = marker.getElementsByTagNam
document.getElementById("[
..
function doHttpRequest() { // This function does the AJAX request
http.open("GET", "poi_info.php", true);
http.onreadystatechange = getHttpRes;
http.send(null);
}
.. where this is the div i'm trying to update:
marker.openInfoWindowHtml(
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK i have tried to implement it as per the attached code snippet, but Firebug is reporting the following error:
missing ) after argument list
http://www.globexposure.net/index.php
Line 100
..which relates to this line:
marker.openInfoWindowHtml( "<div id='iw' style='padding:5px'>"docum ent.getEle mentById(" iw").inner HTML = title+"<br><br>"+date+"</d iv>",{maxC ontent: html, maxTitle: infotitle, noCloseOnClick: true});
What have i missed?
missing ) after argument list
http://www.globexposure.net/index.php
Line 100
..which relates to this line:
marker.openInfoWindowHtml(
What have i missed?
else{
GEvent.addListener(marker, "click", function() {
map.setCenter(marker.getPoint(),maxZoom,G_SATELLITE_MAP);
var title = marker.getElementsByTagName("title").firstChild.nodeValue;
var date = marker.getElementsByTagName("date").firstChild.nodeValue;
marker.openInfoWindowHtml("<div id='iw' style='padding:5px'>"document.getElementById("iw").innerHTML = title+"<br><br>"+date+"</div>",{maxContent: html, maxTitle: infotitle, noCloseOnClick: true});
});
}
ASKER
I already have the attached AJAX (?) request a little further down in my code, which already connects to the file i need. Will this be usable by the code i'm trying to implement now...?
I have attached a copy of my complete script if thats any easier.
I have attached a copy of my complete script if thats any easier.
var request = GXmlHttp.create();
request.open("GET", "http://www.globexposure.net/includes/read.php", true);
request.onreadystatechange = function() {
if (request.readyState == 4) {
var xmlDoc = GXml.parse(request.responseText);
..
index.php.txt
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It got a little further, but now Firebug reports:
marker.getElementsByTagNam e is not a function
http://www.globexposure.net/index.php
Line 98
any ideas?
marker.getElementsByTagNam
http://www.globexposure.net/index.php
Line 98
any ideas?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
If it's using the AJAX request that i already use, that i referred to in my post above...
.. this does return the correct data because it's already used to display some of the same data later on.
Alternatively, how can i confirm this?
.. this does return the correct data because it's already used to display some of the same data later on.
Alternatively, how can i confirm this?
ASKER
var title = marker.getElementsByTagNam
var date = marker.getElementsByTagNam
...using this function:
function doHttpRequest() { // This function does the AJAX request
http.open("GET", "poi_info.php", true);
http.onreadystatechange = getHttpRes;
http.send(null);
}
Am I on the right track/ can you help me formulate this?
Cheers