home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 2733
Discussions: 186,607, Posts: 2,227,057, Members: 230,242
Free Scan: Update Your PC's Outdated Drivers to Optimize Performance
Old September 7th, 2008, 11:27 PM   Digg it!   #1 (permalink)
Junior Member
 
Join Date: Sep 2008
Posts: 18
Exclamation
JavaScript -- for loop with a nested array

What I want to do is have one large array or 'table' and have each of the 160,000 'records' have about 5 'fields' each.

Code:
table = new Array();
table = [
     record[0] = ["field1", "field2", "field3", "field4", "field5"];
     record[1] = ["field6", "field7", "field8", "field4", "field9"];
     record[2] = ["field10", "field11", "field12", "field13", "field14"];
     record[3] = ["field15", "field16", "field17", "field18", "field19"];
     record[4] = ["field20", "field21", "field22", "field23", "field24"];
];
I just wanted to know if this kind of thing was possible or even existed. I've been working too hard to actually think about this--been trying to figure out how for 2 weeks now--and I need help. The only days I have off are tomorrow and the day after, so if I could get a working draft by tomorrow morning I'd be saved! Filling the array won't be a problem at all... I'm working with a small company and their servers aren't incredible so we're trying to get this as much client-side as possible is why I'm trying to do this in JS. Otherwise I'd do this in ASP.NET or something similar. PLEASE HELP. If left to figure this out alone I'll figure it out the hour before I go back to work! :-P

ahmorrow is offline   Reply With Quote
TechIMO.com Ads - Login or register for less ads.
How many errors does your computer have?

You no longer need to guess! This free stability scan and registry cleaner download will give you a complete diagnosis of your Windows registry, identifying errors and conflicts.

FREE instant scan


Guest, Register Free! to remove this ad and get your tech support questions answered in minutes!
Old September 8th, 2008, 11:29 PM     #2 (permalink)
Member
 
Join Date: Oct 2003
Posts: 247
Yeah

Here is how you can do arrays of arrays. You could also use a multidem. array but here is exactly what you want.

Code:
var pets = new Array ( );
pets[0] = new Array ( "Sheba", 13, "cat" );
pets[1] = new Array ( "Jasper", 12, "dog" );

alert ( pets[0][0] + " is a " + pets[0][1] + " year old " + pets[0][2] ); // Displays "Sheba is a 13 year old cat"
alert ( pets[1][0] + " is a " + pets[1][1] + " year old " + pets[1][2] ); // Displays "Jasper is a 12 year old dog"

amtrac24 is offline   Reply With Quote
Old September 8th, 2008, 11:31 PM     #3 (permalink)
Junior Member
 
Join Date: Sep 2008
Posts: 18
Thanks :-)

I'll learn what I need from that. It's for a game I play online, I'm making an online map... big horrible mess. Oh well. Time to get everyone else to collect the information for me >:-)

ahmorrow is offline   Reply With Quote
Old September 8th, 2008, 11:36 PM     #4 (permalink)
Junior Member
 
Join Date: Sep 2008
Posts: 18
Oh and technically speaking JavaScript doesn't support multi-dimensional arrays, I've just never had the need to nest arrays like this and wasn't sure of the syntax. I tried looking it up earlier, but forgot what it was... guess all I needed was a pair of fresh eyes! Thanks :-)
ahmorrow is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ array loop w/ nested if statement problem Ramen Webmastering and Programming 4 February 29th, 2008 12:52 PM
javascript array index issue csamuels Webmastering and Programming 1 November 22nd, 2006 10:26 AM
Excel nested IFs or Index rmanja Applications and Operating Systems 0 November 18th, 2005 07:56 PM
c++ for loop help boogieman063 Webmastering and Programming 5 November 17th, 2004 02:20 PM
Load an array w/ a do/while loop Martoch Webmastering and Programming 6 October 14th, 2002 09:02 PM

Most Active Discussions
Is It Just Me? (530)
Misery Loves Company... (1849)
Why Does the MOON Grow Bigger as It.. (18)
heatsink issue (10)
New Mobo (18)
UPGRADING C/D DRIVE TO 250GB & .. (14)
1 internet. 1 house. 3 computer. ho.. (13)
SSD's, RAID, and External Backup (7)
Is This A Compatible Gaming PC? (18)
Recent Discussions
32 or 64 bit vista (4)
Big problem with my PC (2)
system restore 'next' button wo.. (2)
Building my first PC and need s.. (1)
firewall (1)
C++ compiler suggestions (4)
Official World of Warcraft Thre.. (4529)
Programming question (2)
UPGRADING C/D DRIVE TO 250GB &a.. (14)
FS: Dell 6000 laptop, modded 36.. (2)
Apple iPod touch 16 GB $200 (4)
Six 28-Disc Cross Design Black .. (4)


All times are GMT -4. The time now is 12:19 PM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28