Results 1 to 2 of 2

Thread: javascript 'control arrays', sort of

  1. #1

    Thread Starter
    Frenzied Member ae_jester's Avatar
    Join Date
    Jun 2001
    Location
    Kitchener Ontario Canada Earth
    Posts
    1,545

    javascript 'control arrays', sort of

    Hi,

    I know there is a way to reference images on a webpage by combining the name + the number of the image, but I can't find out how.

    For example, in my checker game animator, I have 64 images (sqr1, sqr2, sqr3, sqr4 etc), one for each square on the board. Since I'm using arrays to store the position of all of the pieces, it would be awesome if I could loop through the images and load the correct piece based on the value in the array

    Something like
    VB Code:
    1. document.controls["sqr" + i].src = '.... bla bla bla

    Although I'm sure that syntax is 100% incorrect.

    Any ideas??

  2. #2
    Lively Member
    Join Date
    Dec 2002
    Location
    southwest pennsylvania
    Posts
    65
    document.all["sqr"+1].src="blah.jpg"
    if you choose not to decide you still have made a choice!

    RUSH rocks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width