Toon posts:

[javascript] loop werkt niet

Pagina: 1
Acties:

Verwijderd

Topicstarter
ik heb dus al een tijdje zitten prutsen (zie postingtijd :'( )
ik heb 2 javascriptjes door elkaar gemengd. Hij doet het bijna, maar hij loopt niet meer goed door. Iemand enig idee wat ik moet fixen?

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title>Example of the text writer script</title>
</head>
<body>

<script language="JavaScript">
<!--

var d
var i=6
var u=0
var time
var symbole

function tableau() {
this[0]="100|. You are out of luck";
this[1]="100|. Maybe some other time";
this[2]="100|. Not this time";
this[3]="100|. Come back later, I'm busy right now";
this[4]="100|. What can I say";

}

function scroll() {
var tb = new tableau()

time = tb[u].substring(0,3) // the substring command is so cool ;)
symbole = tb[u].substring(3,5)

i++

if (i > tb[u].length) {
i = 6
u++
if (u > 5) { u = 0 } // 4 = line number -1
}
d = "<b>Sorry Mate.</b>"+tb[u].substring(5,i)

if(document.getElementById){
document.getElementById('msg').innerHTML=d+symbole;
} else if (document.all){
document.all['msg'].innerHTML = d+symbole
} else if (document.layers){
document.msg.document.write(d+symbole);
document.msg.document.close();
}


setTimeout ("scroll()",time);
}

// -->

</script>

<body onLoad="scroll(0)">
<div id="msg" style="font-size: 10px; font-family: Verdana, Georgia, Arial, Helvetica; border: 1px solid #000000; width: 300px; text-align: left;">
</div>
</form>
</body>
</html>

  • Reptile209
  • Registratie: Juni 2001
  • Nu online

Reptile209

- gers -

Verwijderd schreef op 28 september 2002 @ 01:53:
function tableau() {
this[0]="100|. You are out of luck";
this[1]="100|. Maybe some other time";
this[2]="100|. Not this time";
this[3]="100|. Come back later, I'm busy right now";
this[4]="100|. What can I say";
}

[...]

if (i > tb[u].length) {
i = 6
u++
if (u > 5) { u = 0 } // 4 = line number -1
}
wat dacht je van if (u > 4) ... je hebt immers maar 5 (0..4) messages! Bij mij doet 'ie het zo.
edit:
Welterusten dan maar :Z (zie tijd post :P)

Zo scherp als een voetbal!


Verwijderd

Topicstarter
hehe, dat valt me dan eigelijk nog mee van me zelf :D, thx mate!

  • Annie
  • Registratie: Juni 1999
  • Laatst online: 25-11-2021

Annie

amateur megalomaan

Verwijderd schreef op 28 september 2002 @ 01:53:
time = tb[u].substring(0,3) // the substring command is so cool ;)
B)
>:)

Today's subliminal thought is:


  • Bosmonster
  • Registratie: Juni 2001
  • Laatst online: 29-08 19:47

Bosmonster

*zucht*



Multi-dimensional arrays nog veel cooler.. ;)