Hi Guys hope you can help me

I am using the following AJAX code to get SUB-Buttons.

If no new button is selected I need the main button to revert back to the originally selected main button on mouseout with a timeout function or delay please help.

so the code below works but i need a delay or timout

http://entertainment.iafrica.com/
the above link is what its how its suppost to function.

<script language="JavaScript">
function getXMLHTTP() { //fuction to return the xml http object
  var xmlhttp=false; 
  try{
   xmlhttp=new XMLHttpRequest();
  }
  catch(e) {  
   try{   
    xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
   }
   catch(e){
    try{
    req = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e1){
     xmlhttp=false;
    }
   }
  }
    
  return xmlhttp;
 }
 
 
 
 function getCity(strURL) {  
  
  var req = getXMLHTTP();
  
  if (req) {
   
   req.onreadystatechange = function() {
    if (req.readyState == 4) {
     // only if "OK"
     if (req.status == 200) {      
      document.getElementById('citydiv').innerHTML=req.responseText;      
     } else {
      alert("There was a problem while using XMLHTTP:\n" + req.statusText);
     }
    }    
   }   
   req.open("GET", strURL, true);
   req.send(null);
  }
    
 }
</script>


<td background="images/button_main.gif" class="hand" onMouseOver="getCity('getButtons.php?city=<?php echo $city;?>');" onMouseOut="getCity('getButtons.php?city=<?php echo $original_city;?>');" onClick="">BUTTON</span></td>

adjusted the onmouseout function

<td background="images/button_main.gif" class="hand" onMouseOver="getCity('getButtons.php?city=<?php echo $city;?>');" onMouseOut="setTimeout('getCity(\'getButtons.php?city=<?php echo $original_city;?>\')', 3000);" onClick="">BUTTON</span></td>

Thank you very much, the above was just what i needed. I was close but it was the backslashes that had me confused.

I would also really appreciate it if you could help me with a "clearTimeout" on the "onMouseOver" button so that the sub-menu doesn't jump back to the original menu while you are busy mousing over other buttons?

<td background="images/button_main.gif" class="hand" onMouseOver="getCity('getButtons.php?city=<?php echo $city;?>');clearTimeout();" onMouseOut="setTimeout('getCity(\'getButtons.php?city=<?php echo $original_city;?>\')', 3000);" onClick="">BUTTON</span></td>

Thank you for all the help i finally worked it out.

var timeOut;

<td background="images/button_main.gif" class="hand" onMouseOver="getCity('getButtons.php?city=<?php echo $city;?>');clearTimeout(timeOut);" onMouseOut="timeOut=setTimeout('getCity(\'getButtons.php?city=<?php echo $original_city;?>\')', 3000);" onClick="">BUTTON</span></td>
This question has already been answered. Start a new discussion instead.