Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:26
Dynamic menu calculation via Javascript from an array
Poster: Bischoff
Dated: Tuesday June 1 2004 - 11:23:54 BST
Hi,
for the following problem I would need your help. I am new to the menu system and also rather new to Javascript. So, I would be happy if somebody could help finding my way.
I am programming an online course. The course data is in XML. It comes to my xsl via an array. The menu structure and all the other data is in an array with several dimensions. It looks like this:
var records = new Array();
var textnr = new Array();
<xsl:for-each select="esys2export/record">
records[<xsl:value-of select="position()"/>] = new Array();
records[<xsl:value-of select="position()"/>]["textnr"] = unescape("<xsl:value-of select="textnr"/>");
records[<xsl:value-of select="position()"/>]["menulevel1"] = unescape("<xsl:value-of select="menulevel1"/>");
records[<xsl:value-of select="position()"/>]["menulevel2"] = unescape("<xsl:value-of select="menulevel2"/>");
records[<xsl:value-of select="position()"/>]["menulevel3"] = unescape("<xsl:value-of select="menulevel3"/>");
records[<xsl:value-of select="position()"/>]["titel"] = unescape("<xsl:value-of select="titel"/>");
records[<xsl:value-of select="position()"/>]["text"] = unescape("<xsl:value-of select="titel2"/>");
</xsl:for-each>
Now I have all I need in the array records(). Lets say I get 10 entries in the array records:
[u]records[i][textnr][menulevel1][menulevel2][menulevel3][titel][text][/u]
records[1][001][Session 1][Introduction][plain][Some Titel][blabla]
records[2][002][Session 1][Main Part][Goal of Session 1][Some Titel][blabla]
records[3][003][Session 1][Main Part][Let's learn][Some Titel][blabla]
records[4][004][Session 1][Wrap up][Lessons learned][Some Titel][blabla]
records[5][005][Session 2][Introduction][plain][Some Titel][blabla]
records[6][006][Session 2][Main Part][Goal of Session 1][Some Titel][blabla]
records[7][007][Session 2][Main Part][Let's learn][Some Titel][blabla]
records[8][008][Session 2][Wrap up][Lessons learned][Some Titel][blabla]
records[9][009][Good Bye][plain][plain][Some Titel][blabla]
records[10][010][Literature][Books][plain][blabla]
records[11][011][Literature][Websites][plain][blabla]
I now would need a function to calculate the Milonic menus depending on what is in my array for menulevel1, menulevel2 and menulevel3.
Do you have any working code in Javascript. All I found in the forum was PHP what did not help me.
Thanks,
Kerstin
Poster: Andy
Dated: Tuesday June 1 2004 - 12:46:25 BST
Hi,
Where is this piece of code from?
Code:
var records = new Array();
var textnr = new Array();
<xsl:for-each select="esys2export/record">
records[<xsl:value-of select="position()"/>] = new Array();
records[<xsl:value-of select="position()"/>]["textnr"] = unescape("<xsl:value-of select="textnr"/>");
records[<xsl:value-of select="position()"/>]["menulevel1"] = unescape("<xsl:value-of select="menulevel1"/>");
records[<xsl:value-of select="position()"/>]["menulevel2"] = unescape("<xsl:value-of select="menulevel2"/>");
records[<xsl:value-of select="position()"/>]["menulevel3"] = unescape("<xsl:value-of select="menulevel3"/>");
records[<xsl:value-of select="position()"/>]["titel"] = unescape("<xsl:value-of select="titel"/>");
records[<xsl:value-of select="position()"/>]["text"] = unescape("<xsl:value-of select="titel2"/>");
</xsl:for-each>
var textnr = new Array();
<xsl:for-each select="esys2export/record">
records[<xsl:value-of select="position()"/>] = new Array();
records[<xsl:value-of select="position()"/>]["textnr"] = unescape("<xsl:value-of select="textnr"/>");
records[<xsl:value-of select="position()"/>]["menulevel1"] = unescape("<xsl:value-of select="menulevel1"/>");
records[<xsl:value-of select="position()"/>]["menulevel2"] = unescape("<xsl:value-of select="menulevel2"/>");
records[<xsl:value-of select="position()"/>]["menulevel3"] = unescape("<xsl:value-of select="menulevel3"/>");
records[<xsl:value-of select="position()"/>]["titel"] = unescape("<xsl:value-of select="titel"/>");
records[<xsl:value-of select="position()"/>]["text"] = unescape("<xsl:value-of select="titel2"/>");
</xsl:for-each>
We are currently working on XML based menus but I'd like to know ehere you are declaring the above.
Cheers
Andy
Poster: Bischoff
Dated: Tuesday June 1 2004 - 14:44:44 BST
Hi, this is my own developed code I have in my little program. I do not know about any of your XML's.
I am declaring the array-code in the Head-section of my XSL-File.
My question was now to an routiene for the menus, some kine of For all....
Kerstin