Advertisement
Guest User

Jartaud

a guest
Feb 19th, 2010
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.64 KB | None | 0 0
  1. // Roshan's Ajax dropdown code with php
  2. // This notice must stay intact for legal use
  3. // Copyright reserved to Roshan Bhattarai - nepaliboy007@yahoo.com
  4. // If you have any problem contact me at http://roshanbh.com.np
  5. function getXMLHTTP() { //fuction to return the xml http object
  6.         var xmlhttp=false; 
  7.         try{
  8.             xmlhttp=new XMLHttpRequest();
  9.         }
  10.         catch(e)    {      
  11.             try{           
  12.                 xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
  13.             }
  14.             catch(e){
  15.                 try{
  16.                 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  17.                 }
  18.                 catch(e1){
  19.                     xmlhttp=false;
  20.                 }
  21.             }
  22.         }
  23.            
  24.         return xmlhttp;
  25.     }
  26.    
  27.     function getSubCat(catId) {    
  28.        
  29.         var strURL="../Includes/subcatAds.php?cat="+catId;
  30.         var req = getXMLHTTP();
  31.        
  32.         if (req) {
  33.            
  34.             req.onreadystatechange = function() {
  35.                 if (req.readyState == 4) {
  36.                     // only if "OK"
  37.                     if (req.status == 200) {                       
  38.                         document.getElementById('subcat').innerHTML=req.responseText;                      
  39.                     } else {
  40.                         alert("There was a problem while using XMLHTTP:\n" + req.statusText);
  41.                     }
  42.                 }              
  43.             }          
  44.             req.open("GET", strURL, true);
  45.             req.send(null);
  46.         }      
  47.     }
  48.  
  49.     function getDept(deptId) {     
  50.        
  51.         var strURL="../Includes/dept.php?dept="+deptId;
  52.         var req = getXMLHTTP();
  53.        
  54.         if (req) {
  55.            
  56.             req.onreadystatechange = function() {
  57.                 if (req.readyState == 4) {
  58.                     // only if "OK"
  59.                     if (req.status == 200) {                       
  60.                         document.getElementById('dept_ht').innerHTML=req.responseText;                     
  61.                     } else {
  62.                         alert("There was a problem while using XMLHTTP:\n" + req.statusText);
  63.                     }
  64.                 }              
  65.             }          
  66.             req.open("GET", strURL, true);
  67.             req.send(null);
  68.         }      
  69.     }
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement