1 Replies - 755 Views - Last Post: 05 December 2007 - 06:15 PM

#1 sf242   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 42
  • Joined: 17-July 07

Javascript looping for form...

Post icon  Posted 05 December 2007 - 06:05 PM

i have a php shoutbox on my website. i told it that whenever you hit "send", to change the page title with javascript temporarily. unfortunately, it only works once, or loops infinetely. code:
<script language="Javascript">
var msg = "<?php echo $_SESSION['valid_user']; ?>";
var msg2 = "Eric.RinehartWeb.Net Chat";

var i = 2;
function Blnk() {
loop {
if (i==2) {
document.title = msg;
i = 0;
}
else if (i==0)
{
document.title = msg2;
i = 1;
}
setTimeout("Blnk()", 2300); //2300 is your speed
}
}

</script>


thats just the section for the page title thing. if i set i back to 2 at the last else if, it loops infinetely. if i dont, it works the first time, but not again until i reload the page. I need a way to set it back to 2 with out it looping. please help...

Is This A Good Question/Topic? 0
  • +

Replies To: Javascript looping for form...

#2 William_Wilson   User is offline

  • lost in compilation
  • member icon

Reputation: 207
  • View blog
  • Posts: 4,812
  • Joined: 23-December 05

Re: Javascript looping for form...

Posted 05 December 2007 - 06:15 PM

i do not think the problem is with this code, but rather where and when you are calling it instead. Can we see that code?

Also you could try adding a return statement, depending on your implementation that may help.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1