Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
For loop inside onload(); Adding events not working. :S
Old 01-23-2008, 09:46 PM For loop inside onload(); Adding events not working. :S
stewart's Avatar
Novice Talker

Posts: 11
Name: Stewart Howe
Location: Denver, CO
Trades: 0
Let me explain first....

on www.celermedia.com I have some projects listed and I am doing some js magic for each project. So I am attempting to just go through them all with a for loop and add their appropriate events (mouseover,out,click)...

Here is what currently am trying to do:

Code:
window.onload = function() {
    
    var projects = new Array();
        projects[0] = 'Tbr,http://www.theboardroomsurfandskate.com/';
        projects[1] = 'Gcs,http://www.gulfcoastshop.com/';
        projects[2] = 'Mts,http://www.mytutorialsite.com/';
        projects[3] = 'Mcp,http://www.mycustomportal.com/';
        projects[4] = 'Stew,http://stewart.celermedia.com/';

    for (i=0; i<projects.length; i++) {
        var projData = projects[i].split(',');
        var proj = document.getElementById('proj'+projData[0]);
            proj.onmouseover = function() { projectOn(projData[0]);  }
            proj.onmouseout     = function() { projectOff(projData[0]); }
            proj.onclick     = function() { go(projData[1]); }
    }
}
What I don't get is on the line...
var projData = projects[i].split(',');

If I change my 'i' variable to 0,1,2, etc... it works fine, for that ONE.. why would that work but not when I put in my i variable from my for loop ?


Thanks in advance !
__________________
stewart::howe
Web Developer & Programmer

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
| CelerLabs.com
stewart is offline
Reply With Quote
View Public Profile Visit stewart's homepage!
 
 
Register now for full access!
Old 01-24-2008, 05:21 AM Re: For loop inside onload(); Adding events not working. :S
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,520
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Cancel that I read the code incorrectly.


Need a URL to get ALL the code BTW
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?

Last edited by chrishirst; 01-24-2008 at 05:24 AM..
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-27-2008, 03:03 AM Re: For loop inside onload(); Adding events not working. :S
carloncho's Avatar
Skilled Talker

Posts: 80
Name: Carlos
Trades: 0
I test it, and works! I didnt test in IE 6, but...
You have a position error in your site with IE7: The footer div (copyright...) appears in the middle of the page on top of the content.
__________________
-----------------------

Please login or register to view this content. Registration is FREE
carloncho is offline
Reply With Quote
View Public Profile Visit carloncho's homepage!
 
Reply     « Reply to For loop inside onload(); Adding events not working. :S
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.68173 seconds with 12 queries