Milonic provide full featured pull down web menus for some of the worlds largest companies
click here to see what it can do for you

Download Milonic DHTML Menu
Buy Milonic DHTML Menu

Back To Start Of Archive
Taken From The Forum: Archived Topics for the old Version 3.0 JavaScript Menu
Forum Topic: Click to view post
Last Updated: Wednesday July 18 2012 - 06:07:18

Passing Arguments

Poster: Cool_Capybara
Dated: Thursday November 7 2002 - 19:26:57 GMT

Has anyone had any success with passing arguments using the menu? This may just be a matter of syntax, but I'm trying to pass a value with a link and am not having success.

For example:

In my case, I am passing a php value, so I have something like:

""<?php echo $value>

...any suggestions as to the support and the syntax?


Poster: Cool_Capybara
Dated: Thursday November 7 2002 - 19:39:07 GMT

I just noticed that this site does exactly what I am talking about (in the samples); so I guess it's just a matter of syntax...

Poster: Cool_Capybara
Dated: Friday November 8 2002 - 2:03:24 GMT

Okay, I have it narrowed a bit...and I find it strange that I can't find the answer easily on a Google search.

But it's pretty much just passing a php parameter with a url using Javascript.

So, I have a php variable, say "ID" that I want to pass along to a new page using javascript (the menu in this case). In Javascript, I have the following:



   ,"Sub1", "http://",,,1

   ,"Sub2", ""+"ID=<?php echo $ID; ?>",,,1


But of course, that doesn't work. I get a url of
This site uses what I need in its menu examples, so I imagine the syntax is well known...but I can't find an example of it anywhere!

Thanks for the help.

Poster: kevin3442
Dated: Friday November 8 2002 - 5:01:44 GMT


I'm afraid my knowledge of php is pretty slim, but it looks to me like the menu links to the various examples on pass the parameters as literals, like the Standard Demos menu shown below:
,"Link/Image Based - Static","menusample.php?sampleid=2",,,1
,"Link/image Based - Dynamic","menusample.php?sampleid=10",,,1
,"Horizontal Nav Bar - Common","menusample.php?sampleid=1",,,1
,"Link Information Sample","menusample.php?sampleid=5",,,1

I don't see any use of php commands or variables in any of the example submenus' URLs. I guess my point is that the menus on the site don't seem to be doing exactly what you want to do, if I understand your goal correctly, so they may not be as helpful as you'd like. I haven't seen an example do quite what you want to do (not to say they don't exist). I know that it's not much trouble to incorporate a javascript variable into the URL field of a menu item definition. Could you do something to move the value of your php variable ($ID) into a javascript variable as an intermediary, then use that javascript variable in your menu item's URL? Just a thought. I know that's probably not much help, but it's all I got.


Poster: Cool_Capybara
Dated: Friday November 8 2002 - 5:55:23 GMT

Thanks for your reply.

Damned, you're right. Still, this HAS to be a common requirement and is DEFINTELY possible. I just can't figure the __at__ #$%!! syntax out!

Any other ideas?

Thanks in advance!

Poster: kevin3442
Dated: Friday November 8 2002 - 6:35:14 GMT

Hi again,

Again, I'm not very good with php (although I hope to learn soon). But if I understand the basic idea, php exerts it's effect by being preprocessed through a server-side php interpreter, before the page is rendered... or something like that... right? It seems like your php code is not being interpreted at all, so what you end up with is the result of treating your php code as a simple literal string in javascript. Is it the .php filename extension that invokes the interpreter? I.e., if your menu arrays are defined in an external .js file (as is the norm here; e.g., menu_array.js), will your psp syntax even be preprocessed/interpreted? I seem to recall reading somewhere on this forum that renaming your external .js file to .php will force it to go through the php preprocessor (... interpreter... whatever). Maybe then your code will be interpreted correctly???

(To whomever wrote the post where I read that bit of wisdom, I apologize if I seem to be stealing your thunder. I searched, but can't find the thread where I read that in these forums, so I can't give proper attribution. Then again, I also can't shirk responsibility if it doesn't work! Maybe I read it somewhere else... Maybe I'm going bonkers... It's late... I have a toddler... which is why I have to be up so late to get my work done... begging the question of why am I screwing around in on-line forums, when I should be working? Back to work.) ;)

A stab in the dark...


Poster: Cool_Capybara
Dated: Friday November 8 2002 - 9:37:39 GMT

Hmmm... not a bad idea. Yes, the php code is interpreted inline. It's invoked by <?php or <? or <script=php> etc. but even if it wasn't being invoked, I would expect to see the address as a literal. In my case, it's being cut off. I get:<?php

Not sure why it stops at the space even when in the double quotes.

Still I can see your idea possibly working. I can make the whole menu a php file and run javascript within the php file. I would then include the php file in my main page. I may just give that a try. Thanks for the suggestion.

Poster: Cool_Capybara
Dated: Saturday November 9 2002 - 0:44:31 GMT

Kevin -- just to let you know, it worked like a charm! Thanks for the suggestion! :D

Poster: kevin3442
Dated: Saturday November 9 2002 - 4:22:54 GMT

Cool! Glad it worked. Although I was just parroting something I read elsewhere. Even so, I'll have to keep it in mind when I start delving into php.



Poster: F. Jeffe
Dated: Thursday November 14 2002 - 18:48:54 GMT

Hello Cool_Capybara (& Kevin),

I also got into troubles when I tried to get the menu working with PHP. In my case the link I try to invoke within the menu has to be something like:
link.php?init=$init&volgord=offno. As you can see init should be replaced by data submitted when loggin in on the website. The problem you struggled with seems to be in the same order and I understood from your digital conversation that some achievement has been made.
Could I be so brutal as to ask you to explain how you did it and even perhaps have the code for it? I would be much obliged since I am working on this for two whole days and don't seem to get any further with it.

Hope to hear from you...

F. Jeffe
Rijswijk (the Netherlands)

Poster: jbreslow
Dated: Tuesday December 2 2003 - 17:42:18 GMT

Works for ColdFusion too... making the .js file into a .cfm allowed me to pass variables to the menu without a problem.

Thank you sooo much!!!!