Toon posts:

[JS] javascript loop

Pagina: 1
Acties:

Verwijderd

Topicstarter
Ik heb hier een javascript loopje gescreven. Maar ik krijg het niet voor elkaar om de "test" variable tussen document. en .src te krijgen. Kan iemand mij helpen? Wat doe ik fout?

for (i = 1; i <= 50; i++)
{
var test = "pijl" + i;
if (imgNr==i)
{
document.+test+.src="/Images/submenu_pijl.gif";
}
}

  • r0bert
  • Registratie: September 2001
  • Laatst online: 11-08 16:19
document.images[test].src="/Images/submenu_pijl.gif";
of
document.getElementById(test).src="/Images/submenu_pijl.gif";

  • BtM909
  • Registratie: Juni 2000
  • Niet online

BtM909

Watch out Guys...

Wat heb je al geprobeerd?

Wat ik zou proberen:

JavaScript:
1
2
document.images[test].src = '';
document.getElementById(test).src = '';

[ Voor 18% gewijzigd door BtM909 op 16-05-2003 14:56 . Reden: damn you r0bert ;) ]

Ace of Base vs Charli XCX - All That She Boom Claps (RMT) | Clean Bandit vs Galantis - I'd Rather Be You (RMT)
You've moved up on my notch-list. You have 1 notch
I have a black belt in Kung Flu.


Verwijderd

Topicstarter
Mega bedankt. Hij doet het.

document.getElementById(test).src="/Images/submenu_pijl.gif";