473,703 Members | 2,340 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

setInterval(F(x ));

Hoe can I use setInterval where its argument is a function which also has an argument? For example I have a function change(Msg) where Msg is dynamically generated and returns nothing at this point (other than true I guess). I would like to have setInterval(cha nge(Msg)); but that doesn't work. Any suggestions? Thanks.

--
George Hester
_______________ _______________ ____
Jul 23 '05 #1
17 2124
On Thu, 29 Jul 2004 20:02:31 +0000, George Hester wrote:
Hoe can I use setInterval where its argument is a function which also
has an argument? For example I have a function change(Msg) where Msg is
dynamically generated and returns nothing at this point (other than true
I guess). I would like to have setInterval(cha nge(Msg)); but that
doesn't work. Any suggestions? Thanks.


Who you callin' a hoe?!?!

JavaScript encapsulated in PHP:

print("setInter val(\"GetTime(d ocument.getElem entById('\" + TimeAnchor.id
+\"'))\", 1000);");

Let me see if I can strip out the PHP for you:

setInterval("Ge tTime(document. getElementById( ' + TimeAnchor.id +')),
1000);");

Calls a function with setInterval and passes an argument to that function.
--
i.m.
The USA Patriot Act is the most unpatriotic act in American history.

Jul 23 '05 #2
No one except my clumsy digits.

I tried it. I didn't work. Let me be nore specific:

Msg = "1<div>2<div>3< div>4<div>5<div >6"

change() just changes the visibility status of a div in the page. When Msg="" then the div is hidden. When Msg<>"" then the div is visible.

So I did this:

setInterval("ch ange('+Msg+');" ); which I believe is what you had. First the string concatenation doesn't look right and so I can understand why it doesn't work. I did try setInterval("ch ange("+Msg+")") ; but no good also. Thanks though.

--
George Hester
_______________ _______________ ____
"Ivan Marsh" <an*****@you.no w> wrote in message news:pa******** *************** ***@you.now...
On Thu, 29 Jul 2004 20:02:31 +0000, George Hester wrote:
Hoe can I use setInterval where its argument is a function which also
has an argument? For example I have a function change(Msg) where Msg is
dynamically generated and returns nothing at this point (other than true
I guess). I would like to have setInterval(cha nge(Msg)); but that
doesn't work. Any suggestions? Thanks.


Who you callin' a hoe?!?!

JavaScript encapsulated in PHP:

print("setInter val(\"GetTime(d ocument.getElem entById('\" + TimeAnchor.id
+\"'))\", 1000);");

Let me see if I can strip out the PHP for you:

setInterval("Ge tTime(document. getElementById( ' + TimeAnchor.id +')),
1000);");

Calls a function with setInterval and passes an argument to that function.


--
i.m.
The USA Patriot Act is the most unpatriotic act in American history.

Jul 23 '05 #3
George Hester wrote:
No one except my clumsy digits.

I tried it. I didn't work. Let me be nore specific:

Msg = "1<div>2<div>3< div>4<div>5<div >6"
change() just changes the visibility status of a div in the page.
When Msg="" then the div is hidden. When Msg<>"" then the div is visible.
So I did this:
setInterval("ch ange('+Msg+');" ); which I believe is what you had.
First the string concatenation doesn't look right and so I can
understand why it doesn't work. I did try setInterval("ch ange("+Msg+")") ;
but no good also. Thanks though.


If you are checking the status of Msg, then let the change function do it.

function change(){
if (Msg != ""){
//Msg isn't empty, act accordingly
}
else{
//Msg is empty, act accordingly
}
}
Jul 23 '05 #4
Yes that did it. I don't like the result. The div blinks. I think I can stop it but I'm not sure if that will be enough.
What is happening is I have a cube which rotates. The faces of the cube are links. When the mouse is over a face my div
pops up which shows the face's links in a more organized fashion. Without this div the loaction of where the links
are going to only shows in the status bar. What I want is the <div's child <divs to highlight corresponding to the
face the mouse is over. This cube is an applet and no I do not have permission to recompile or alter it.. I can only
use what I have and the author did not incorporate a way to use JavaScript in the Java applet. So what you've seen
is my idea.

I will setInterval on change (forms the div) onmouseover. Then I will have the innerHTML set one of the child <div's
with a class. That class will have style different then the other 5 divs. See that's my idea. Trouble is I get flicker.
Well back to the drawing board. Thanks for all your help.

--
George Hester
_______________ _______________ ____
"Randy Webb" <Hi************ @aol.com> wrote in message news:a4******** ************@co mcast.com...
George Hester wrote:
No one except my clumsy digits.

I tried it. I didn't work. Let me be nore specific:

Msg = "1<div>2<div>3< div>4<div>5<div >6"


change() just changes the visibility status of a div in the page.
When Msg="" then the div is hidden. When Msg<>"" then the div is visible.
So I did this:
setInterval("ch ange('+Msg+');" ); which I believe is what you had.
First the string concatenation doesn't look right and so I can
understand why it doesn't work. I did try setInterval("ch ange("+Msg+")") ;
but no good also. Thanks though.


If you are checking the status of Msg, then let the change function do it.

function change(){
if (Msg != ""){
//Msg isn't empty, act accordingly
}
else{
//Msg is empty, act accordingly
}
}

Jul 23 '05 #5
On Thu, 29 Jul 2004 20:46:14 +0000, George Hester wrote:
I tried it. I didn't work. Let me be nore specific:

Msg = "1<div>2<div>3< div>4<div>5<div >6"

change() just changes the visibility status of a div in the page. When
Msg="" then the div is hidden. When Msg<>"" then the div is visible.

So I did this:

setInterval("ch ange('+Msg+');" ); which I believe is what you had. First
the string concatenation doesn't look right and so I can understand why
it doesn't work. I did try setInterval("ch ange("+Msg+")") ; but no good
also.
Thanks though.


I assure you the PHP example I gave you works. I'm not sure if I got the
pure JavaScript example right.

Does your function work if it's not being called by setInterval? Make sure
the function itself works before you try to use setInterval because
debugging it inside setInterval is a nightmare.

Oop... wait a second... I just found an example I wrote that isn't
encapsulated in PHP:

<html>
<head>
<title>clock</title>
<script type='text/JavaScript'>
function GetTime(TimeAnc hor) {
today = new Date();
TimeAnchor.inne rHTML = today.toLocaleS tring(); delete today;
}
function UpdateTime(Time Anchor) {
GetTime(TimeAnc hor);
setInterval("Ge tTime(document. getElementById( '" + TimeAnchor.id +
"'))", 1000);
}
</script>
</head>
<body>
<span id='DateTime'></span>
<script type='text/JavaScript'>
UpdateTime(docu ment.getElement ById("DateTime" ));
</script>
</body>
</html>

This should print a running clock on the page (works in IE and Moz).

--
i.m.
The USA Patriot Act is the most unpatriotic act in American history.

Jul 23 '05 #6
Hey Ivan thanks for that. I think I can use your example in another area. The one I was trying
it doesn't look like it was a good idea. I cannot set the intveral to match with the active links. Being in a
applet it's not pleasant. I might still be able to use it using the changing status bar message but say la vie
for now.

--
George Hester
_______________ _______________ ____
"Ivan Marsh" <an*****@you.no w> wrote in message news:pa******** *************** *****@you.now.. .
On Thu, 29 Jul 2004 20:46:14 +0000, George Hester wrote:
I tried it. I didn't work. Let me be nore specific:

Msg = "1<div>2<div>3< div>4<div>5<div >6"

change() just changes the visibility status of a div in the page. When
Msg="" then the div is hidden. When Msg<>"" then the div is visible.

So I did this:

setInterval("ch ange('+Msg+');" ); which I believe is what you had. First
the string concatenation doesn't look right and so I can understand why
it doesn't work. I did try setInterval("ch ange("+Msg+")") ; but no good
also.
Thanks though.


I assure you the PHP example I gave you works. I'm not sure if I got the
pure JavaScript example right.

Does your function work if it's not being called by setInterval? Make sure
the function itself works before you try to use setInterval because
debugging it inside setInterval is a nightmare.

Oop... wait a second... I just found an example I wrote that isn't
encapsulated in PHP:

<html>
<head>
<title>clock</title>
<script type='text/JavaScript'>
function GetTime(TimeAnc hor) {
today = new Date();
TimeAnchor.inne rHTML = today.toLocaleS tring(); delete today;
}
function UpdateTime(Time Anchor) {
GetTime(TimeAnc hor);
setInterval("Ge tTime(document. getElementById( '" + TimeAnchor.id +
"'))", 1000);
}
</script>
</head>
<body>
<span id='DateTime'></span>
<script type='text/JavaScript'>
UpdateTime(docu ment.getElement ById("DateTime" ));
</script>
</body>
</html>

This should print a running clock on the page (works in IE and Moz).

--
i.m.
The USA Patriot Act is the most unpatriotic act in American history.

Jul 23 '05 #7
JRS: In article <pa************ *************** *@you.now>, dated Thu, 29
Jul 2004 17:34:33, seen in news:comp.lang. javascript, Ivan Marsh
<an*****@you.no w> posted :
setInterval("Ge tTime(document. getElementById( '" + TimeAnchor.id +
"'))", 1000); This should print a running clock on the page (works in IE and Moz).


I expect that you will find that it leaps over a second at intervals
dependent on the OS. See below.

--
John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4
<URL:http://jibbering.com/faq/> JL / RC : FAQ for news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #8
On Fri, 30 Jul 2004 15:59:59 +0100, Dr John Stockton wrote:
JRS: In article <pa************ *************** *@you.now>, dated Thu, 29
Jul 2004 17:34:33, seen in news:comp.lang. javascript, Ivan Marsh
<an*****@you.no w> posted :
setInterval("Ge tTime(document. getElementById( '" + TimeAnchor.id +
"'))", 1000);

This should print a running clock on the page (works in IE and Moz).


I expect that you will find that it leaps over a second at intervals
dependent on the OS. See below.


I'm not too worried about my clock being inacurate by a half-second every
five minutes.

--
i.m.
The USA Patriot Act is the most unpatriotic act in American history.

Jul 23 '05 #9
JRS: In article <pa************ *************** *@you.now>, dated Fri, 30
Jul 2004 15:32:10, seen in news:comp.lang. javascript, Ivan Marsh
<an*****@you.no w> posted :
On Fri, 30 Jul 2004 15:59:59 +0100, Dr John Stockton wrote:
JRS: In article <pa************ *************** *@you.now>, dated Thu, 29
Jul 2004 17:34:33, seen in news:comp.lang. javascript, Ivan Marsh
<an*****@you.no w> posted :
setInterval("Ge tTime(document. getElementById( '" + TimeAnchor.id +
"'))", 1000);

This should print a running clock on the page (works in IE and Moz).


I expect that you will find that it leaps over a second at intervals
dependent on the OS. See below.


I'm not too worried about my clock being inacurate by a half-second every
five minutes.


It is both untidy and easily avoided; and is some systems it will be
substantially more frequent.

--
John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME.
Web <URL:http://www.merlyn.demo n.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Jul 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.