what am i doing wrong?

G

Guest

hey all,

i have the following client-side functions:
<script language=javascript>
function test(){
window.setInterval("sndmsg",10000)
}
function sndmsg(){
alert("HelloWorld!!")
}
</script>

Here's my server-side script:
Private Sub Page_Load(...)
Me.Button1.Attributes.Add("onclick", "javascript:test();")
End Sub

What i thought is should do is send an alert every 10 seconds. Please advise.

thanks,
rodchar
 
G

Guest

the test function runs (i tested with alert message) however in debug it does
execute the window.setInterval but after that nothing happens (no alerts), it
just sits there.
 
G

Guest

that didn't work. it's not even going to the sndmsg() function. am i using
the setInterval wrong or something?

thanks,
rodchar
 
G

Guest

great i see the error of my ways but shouldn't the alert popup every 10
seconds? it pops up when i first push the button but none after that?

thanks,
rodchar

Alvin Bruney - ASP.NET MVP said:
You need to specifiy the function correctly. See
http://msdn.microsoft.com/library/d...uthor/dhtml/reference/methods/setinterval.asp

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------



rodchar said:
that didn't work. it's not even going to the sndmsg() function. am i using
the setInterval wrong or something?

thanks,
rodchar
 
A

agapeton

First off, it's type="text/javascript", that language="" stuff is
deprecated and doesn't belong on the web.

Secondly, it's onclick="test();". Having the javascript: prefix(which
is taboo at best) is redundant.

<head>
<title></title>
<script type="text/javascript">
function sndmsg(){
alert("HelloWorld!!")
}

function test( ) {
window.setInterval("sndmsg()", 1000);
}
</script>
</head>

<body>
<input type="button" id="btnTest" value="Click me!"
onclick="test();">
</body>


David Betz
http://www.davidbetz.net/dynamicbliss/
http://www.davidbetz.net/winfx/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top