View Full Version : Creating and populating multidimensional arrays usings XML

12-09-2004, 12:10 PM
I have a script which takes data from various multidimensional arrays and prints this content as links into a specific div on the page. (thanks to all who helped on that!). Problem is that the arrays cannot be hardcoded but must be created dynamically. Probably from an XML file.

The array will ultimately need to look similar to this :

var myAarray= new Array()

this is the function that then prints that array as links:

function printA(){
document.getElementById('test').innerHTML = '';
var root = document.getElementById('test');
for (i=0; i<myAarray.length; i++){
var a = document.createElement('a');
var n = document.createTextNode(myAarray[i][0]);
var br = document.createElement('br');

Is it possible to create a function that would create these arrays (one for each letter of the alphabet) in the format above, and then once that function is completed to simply call the printA() function?

Again, any help on this hugely appreciated.


12-09-2004, 01:24 PM
Sorry, but I've since discovered all links can be hardcoded into the header and will not require xml.

At present I have a separate function for each letter (printA(), printB() etc.)
which is pretty unwieldly and space consuming. Each of these functions is calling on a seperate array. What I am trying to do is create a single array which contains all entries for all letters, and then adjust the 'print' function so that, depending which letter is selected , it will cycle through the array and print the letter details only related to that selected.

I really hope this makes sense to someone, as its beginning to make less and less sense to me!