Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

settimeout and passing object ID, please help :)

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi, I am totally confused on passing object arguements in DHTML. I don't know when to use '' or "" or non at all.
I am trying to use settimeout method to make a link visible after a certian amount of time, but it doesn't seem to work when I try to pass the link id arguement to my "start(linkid)" function. I get the error "'oid' is undefined"
I dont' understand how dhtml passes object arguments. PLease help!
Thanks!


-thedrak

please email me:
psun1@hotmail.com
------------------------------------------------------------

<HTML>
<HEAD>
<script>
function unhide(which){
which.style.visibility = &quot;visible&quot;;
}
function start(oid){
siID = window.setTimeout(&quot;unhide(oid)&quot;,3500);
}
function stop(){
window.clearTimeout(siID);
}
</script>

<TITLE></TITLE>
</HEAD>
<BODY>
<P> </P>
<P>
<TABLE cellSpacing=1 cellPadding=1 width=&quot;200&quot; border=1 style=&quot;WIDTH: 200px; HEIGHT: 27px&quot; id=table1 onmouseover = &quot;start(timed1)&quot;>
<TR>
<TD>mouseover to start timer</TD></TR></TABLE></P>
<P> </P>
<P> </P>
<div><P><A href=&quot; id=timed1 style=&quot;VISIBILITY: hidden&quot;>timed link1</A></P></div>
</BODY>
</HTML>
 
firstly id put the id on your container div and show/hide that instead of the anchor. the onmouseover event can still be on the anchor but it is better practice for cross browser compatability to use the div.

Hoiw you pass arguements depends primarily on the nature of the arguement. If you pass

myfunc(var1);

you have called the function 'myfunc' and passed the variable var1. The browser will find the variable var1 and use its value for the arguement. However if you passed

myfunc(&quot;var1&quot;);

then you have passed the function the string var1. It doesnt matter wether you use single or double quotes if the argument is quoted you are passing the function a string which will be used in exactly that format whereas unquoted you pass a variable which can contain its own value - a string, a number or a boolean for example. In your case you are passing the id of the element. This isnt a variable its a string which matches the id of the element so it would be quoted like this

start('timed1');

or this

start(&quot;timed1&quot;);

The variable oid(argument) in the function start now contains the string 'timed1' so when you pass oid to the unhide function you dont quote it as you are now passing the variable not the string

unhide(oid);

the variable which inside the unhide function would now represent the string 'timed1';

hope this helps

rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top