| We hope you enjoy your visit. You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free. Join our community! If you're already a member please log in to your account to access all of our features: |
| Javascript; Quick bugshoot please | |
|---|---|
| Tweet Topic Started: Apr 17 2005, 12:45 PM (392 Views) | |
| JoeC | Apr 17 2005, 12:45 PM Post #1 |
|
Euch! IE tastes horrible!
![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
OK, that's my script, in the Head of my HTML page. I then call it later, four times, with
But, some of the links show fine, while others show up as "undefined". I think I'm missing something stupidly obvious. Any help please? Also, sometimes the Alt text shows, while other times, the "user posted image" comes up. Help? |
![]() |
|
| EvilSteve | Apr 17 2005, 11:12 PM Post #2 |
|
Member
![]() ![]() ![]()
|
Hey man, give this a try:
I think your main problem was in the line that creates the random number. If you use round, sometimes it rounds up and sometimes it rounds down, and if it was getting rounded up, the index you were using for your arrays was going out of bounds and giving you "undefined"s. I also switched the code to use regular JavaScript Arrays, and moved the array creation outside of the function code so that the arrays only need to be created once instead of everytime the function is called. |
![]() |
|
| 1 user reading this topic (1 Guest and 0 Anonymous) | |
| « Previous Topic · Technology Chat · Next Topic » |
| Track Topic · E-mail Topic |
4:03 PM Jul 11
|



![]](../../../../0/1/0/p601690/pipright.png)



4:03 PM Jul 11