Click to See Complete Forum and Search --> : help modifying this script to include a time out


sciguyryan
08-20-2003, 05:32 AM
hi all,


can anyone help me modify this script so that the writing that appeares under the dropdown menu (the page description)(the code in blue)stays for 5 seconds and, then dissapears. if you could provide a code for this i would be most greatfull.
thank you in advance.


here's the script:
<form name="a294" >
<select name="a969" size="1" style="background-color:#FFFFFF" onChange="displaydesc(document.a294.a969.selectedIndex)">
<option selected value="http://www14.brinkster.com/fejinwales/default.htm" target="newwin">Home Page</option>
<option value="http://www14.brinkster.com/fejinwales/b5wallpapers.htm" target="newwin">Babylon 5 Wallpapers</option>
<option value="http://www14.brinkster.com/fejinwales/jubilee.htm" target="newwin">Eileen Place Jubilee Pictures</option>
<option value="http://www14.brinkster.com/fejinwales/personal.htm" target="newwin">My Family And Animals</option>
</select>
<input type="button" value="Go"
onClick="jumptolink(document.a294.a969.selectedIndex)"><br>
<span id="descriptions" align="left" style="font:italic 13px Arial">
</span>
</form>
<script>
<!--//CUSTOMIZE TEXT DESCRIPTIONS FOR LINKS ABOVE
var textdisplay=new Array()
textdisplay[0]="TO MY HOME PAGE"
textdisplay[1]="TO MY BABYLON 5 WALLPAPERS"
textdisplay[2]="TO THE EILEEN PLACE STREET PARTY PAGE"
textdisplay[3]="TO PERSONAL (Family & Other Animals)PAGE"
function jumptolink(what){
var selectedopt=document.a294.a969.options[what]
if (document.getElementById && selectedopt.getAttribute("target")=="newwin")
window.open(selectedopt.value)
else
window.location=selectedopt.value
}
function displaydesc(which){
if (document.all)
descriptions.innerHTML=textdisplay[which]
else if (document.getElementById)
document.getElementById("descriptions").innerHTML=textdisplay[which]
}
displaydesc(document.a294.a969.selectedIndex)
document.a294.a969.options[0].selected=true
//-->
</script>]

Fang
08-20-2003, 07:54 AM
Change the function and add the glogal variable:

var timerID=null;
function displaydesc(which){
if (document.all)
descriptions.innerHTML=textdisplay[which]
else if (document.getElementById)
document.getElementById("descriptions").innerHTML=textdisplay[which]
clearTimeout(timerID);
timerID=setTimeout('document.getElementById("descriptions").innerHTML="";',5000);
}

sciguyryan
08-20-2003, 08:08 AM
hi fang...


could you help us' with that? Every time i change something the whole thing stops working.....

Fang
08-20-2003, 08:13 AM
Just replace your function displaydesc(which) with mine and add var timerID=null; as a global variable.
I tested the solution in IE and Mozilla.

sciguyryan
08-20-2003, 08:17 AM
hi,


thank you for helping fang. I've got it now (with your help!)