I fixed the function but now it just doesn’t do what I want. I want it to have a delay when I mouse out. setTimer is just says for it to stay visable for 3.5 seconds. How do I get the delay effect?
You seem to be assuming the function is not being fired after 3.5 seconds rather than the function is not doing what you expect it to do.
A simple debug step would be to put a couple alerts in the function. One so you are alerted when the function is executed and two what the conditional is true.
In sounds like you have the onmouseout event tied to a <SELECT>.
Now there are two components to this the select box itself and the dropdown list. As soon as you move onto the list your mouseout event is fired. That is the dropdown list is not an extension of the control.
Whilst your in the confines of the select itself you will not get the control (unless you are experiencing the time delay). If you make the dropdown list appear and move very slightly into it the alert will be given.
You can avoid all of these problems by using an onchange handler instead of an onmouseout. This will only fire after you have made your choice. Here is the script.
var theSelect;
window.onload = function ()
{ theSelect = document.getElementById(“idcomp”);
theSelect.onchange = function () {
setTimeout(“alert(‘hello’)”, 1000);
}
}
Please note that I have changed the way you wrote the timeout. The first component only needs to be a javascript statement, so you can get rid of the function call and use the script directly as I have done.