473,624 Members | 2,252 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JavaScript MultiDimensiona l Array read array name

Jezternz
145 New Member
First of all I am open to any suggestions and advice. If a javscript multidimensiona l array is a bad way to do this please say so. I considered XML but I wondered if this would be a bad idea as it would be slower for jsp to handel.

Okay here is an example of my multidimensiona l array (only part of it)(bottom of the post). It works fine I can call any of the 3rd dimension without trouble.

Now How would I go about printing something like this from the array:

[HTML]
<table><tr><t d colspan=2>1st dimension name</td></tr>
<tr><td>Secon d Dimension name</td><td>Third Dimension Property</td></tr></table>
[/HTML]

I guess what Im really asking is how to print the name of an array.
Obviously I can access the third dimension by just acessing array[0][0][0] however when I try return array[0][0] it just returns all the contents of [0][0] and not the name of [0][0] itself.

Not sure if I made that clear or not. Can I retrieve an array name somehow? (an array that is inside another arry)

Expand|Select|Wrap|Line Numbers
  1. var css_properties = new Array();
  2.  
  3. var background = new Array;
  4.     css_properties[0] = background;
  5. var border = new Array;
  6.     css_properties[1] = border;
  7.  
  8. var background_attachment = new Array();
  9. css_properties[0][0] = background_attachment;
  10.     css_properties[0][0][0] = 'scroll';
  11.     css_properties[0][0][1] = 'fixed';    
  12. var background_color = new Array();
  13. css_properties[0][1] = background_color;
  14.     css_properties[0][1][0] = 'custom';
  15.     css_properties[0][1][1] = 'transparent';
  16. var background_image = new Array();
  17. css_properties[0][2] = background_image;
  18.     css_properties[0][2][0] = 'custom';
  19.     css_properties[0][2][1] = 'none';
  20.  
  21.  
  22. var border_top_color = new Array();
  23. css_properties[1][0] = border_top_color;
  24.     css_properties[1][0][1] = 'custom';
  25.     css_properties[1][0][0] = 'transparent';
  26. var border_top_style = new Array();
  27. css_properties[1][1] = border_top_style;
  28.     css_properties[1][1][0] = 'none';
  29.     css_properties[1][1][1] = 'hidden';
  30.     css_properties[1][1][2] = 'dotted';
  31.     css_properties[1][1][3] = 'dashed';
  32.     css_properties[1][1][4] = 'solid';
  33.     css_properties[1][1][5] = 'double';
  34.     css_properties[1][1][6] = 'groove';
  35.     css_properties[1][1][7] = 'ridge';
  36.     css_properties[1][1][8] = 'inset';
  37.     css_properties[1][1][9] = 'outset';
  38. var border_top_width = new Array();
  39. css_properties[1][2] = border_top_width;
  40.     css_properties[1][2][0] = 'custom';
  41.     css_properties[1][2][1] = 'thin';
  42.     css_properties[1][2][2] = 'medium';
  43.     css_properties[1][2][3] = 'thick';
  44.  
  45.  
Apr 2 '08 #1
4 2505
hsriat
1,654 Recognized Expert Top Contributor
There is nothing called name in such case.

I mean first you write:
var border_top_colo r = new Array();
Here you declared the array
css_properties[1][0] = border_top_colo r;
Here you copied the array to the css_properties[1][0]. Name of the array , border_top_colo r is not retrieved anywhere.

Don't confuse the XML format to be similar to a multidimensiona l Array.

For the solution of the question, you can do this thing though:
Expand|Select|Wrap|Line Numbers
  1. //var border_top_color = new Array();
  2. //css_properties[1][0] = border_top_color;
  3.     css_properties[1][0]['name'] = 'border_top_color';
  4.     css_properties[1][0][1] = 'custom';
  5.     css_properties[1][0][0] = 'transparent';
And use the index name where required.

Regards,
Harpreet
Apr 2 '08 #2
Jezternz
145 New Member
so this would be better then an xml file? (faster)
Thanks for your help, Much apreciated.

Josh
Apr 2 '08 #3
pronerd
392 Recognized Expert Contributor
so this would be better then an xml file? (faster)
Unless it is a huge amount of data, it is not going to make a difference.
Apr 2 '08 #4
Jezternz
145 New Member
Ok, cheerz. Array it is!
Apr 3 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
6743
by: Golf Nut | last post by:
I am finding that altering and affecting values in elements in multidimensional arrays is a huge pain in the ass. I cannot seem to find a consistent way to assign values to arrays. Foreach would clearly be the most efficient way to do it, but it only works on a copy of the original array and not the original (which is counter intuitive in my estimation). Using each doesn't work consistently either. Not only that, it's unduly complex for...
5
28347
by: Keiron Waites | last post by:
<script language="JavaScript" type="text/javascript"> <!-- var array1 = new Array(); var array1i = new Array(); array1 = array1i; alert(array1); // --> </script>
2
1523
by: Ivan | last post by:
In my HTML forms (created by PHP) for attribute names I have been using multidimensional arrays as illustrated in the following: <table> <tr> <td> ID </td> <td> <input TYPE=hidden Name=frm_s Value=1661></td> <td> <input TYPE=hidden Name=frm_s Value=1662></td> <td> <input TYPE=hidden Name=frm_s Value=1663></td>
13
2505
by: Kevin | last post by:
Help! Why are none of these valid? var arrayName = new Array(); arrayName = new Array('alpha_val', 1); arrayName = ; I'm creating/writing the array on the server side from Perl, but I
22
4598
by: VK | last post by:
A while ago I proposed to update info in the group FAQ section, but I dropped the discussion using the approach "No matter what color the cat is as long as it still hounts the mice". Over the last month I had enough of extra proof that the cat doesn't hount mice anymore in more and more situations. And the surrent sicretisme among array and hash is the base for it. I summarized all points in this article:...
9
6664
by: Charles Banas | last post by:
i've got an interesting peice of code i'm maintaining, and i'd like to get some opinions and comments on it, hopefully so i can gain some sort of insight as to why this works. at the top of the function (which was translated from Fortran code), among other heinous and numerous declarations, is this bit: static float bbuff; static int bkey; static int buse;
4
2679
by: Kobu | last post by:
I've read the FAQ and several posts on multidimensional arrays and how their names decay to pointer to arrays (not pointer to pointers). If this is so, why does the following code fragment compiler and run correctly?: #include <stdio.h> int main()
11
2093
by: Joshua Russell | last post by:
Hi, I wish to parse an XML file into some sort or array or multidimensional storage. The XML file is as follows (without any parent tags just to give you an idea of the structure)... <Ship Name="Disrupter" Class="CC" PrimaryTarget="CR" BattleOrder="1" Guns="5" Power="2"></Ship> <Ship Name="Zealot" Class="CR" PrimaryTarget="CC" BattleOrder="2" Guns="25" Power="5"></Ship> <Ship Name="Drone" Class="CC" PrimaryTarget="CC" BattleOrder="3"...
104
16922
by: Leszek | last post by:
Hi. Is it possible in javascript to operate on an array without knowing how mamy elements it has? What i want to do is sending an array to a script, and this script should add all values from that array Could you show me a little example how to do this? Thanks.
0
8177
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8629
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8341
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7170
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6112
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2611
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1793
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1488
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.