Excerpt: One of the members on Irish WebMaster Forums asked for help in creating a simple dependent select menu and the most obvious option is by using Ajax, so I decided to put up this post with step-by-step instructions.
First, create a new PHP page (as we are going to use php for this) and name it "page1.php".
On this page we are going to add the following javascript code, which will take care of our XMLHTTP request.
<script type="text/javascript" language="javascript">
var ewd_domain = 'http://www.eire-webdesign.ie/'; //set domain
var ewd_loading_img = ewd_domain + 'images/loading.gif';//set image path
var ewd_loading_msg = 'Loading Data…';//set loading message
var xmlhttp_obj = false;
//create the XMLHttpRequest
function ewd_xmlhttp(){
if (window.XMLHttpRequest){ // if Mozilla, Safari etc
xmlhttp_obj = new XMLHttpRequest();
}else if (window.ActiveXObject){ // if IE
try{
xmlhttp_obj = new ActiveXObject("Msxml2.XMLHTTP");
}catch (e){
try{
xmlhttp_obj = new ActiveXObject("Microsoft.XMLHTTP");
}catch (e){
}
}
}else{
xmlhttp_obj = false;
}
return xmlhttp_obj;
} //get content via GET
function ewd_getcontent(url, containerid){
var xmlhttp_obj = ewd_xmlhttp();
document.getElementById(containerid).innerHTML = '<img src="' + ewd_loading_img + '" />' + ewd_load
...
read more »
...






(3 votes, average: 4.67 out of 5)









