Passing Arguments
-
- Beginner
- Posts: 8
- Joined: Tue Nov 05, 2002 2:17 am
Passing Arguments
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:
Domain.com/page.html?argument=value
In my case, I am passing a php value, so I have something like:
"Domain.com/page.php?argument="<?php echo $value>
...any suggestions as to the support and the syntax?
Thanks!
For example:
Domain.com/page.html?argument=value
In my case, I am passing a php value, so I have something like:
"Domain.com/page.php?argument="<?php echo $value>
...any suggestions as to the support and the syntax?
Thanks!
-
- Beginner
- Posts: 8
- Joined: Tue Nov 05, 2002 2:17 am
-
- Beginner
- Posts: 8
- Joined: Tue Nov 05, 2002 2:17 am
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:
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.
[/quote]
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:
Code: Select all
addmenu(menu=["Page",
,,110,1,"",style1,,"",effect,,,,,,,,,,,,
,"Sub1", "http://",,,1
,"Sub2", "http://www.domain.com/page.php?"+"ID=<?php echo $ID; ?>",,,1
])
Code: Select all
http://www.domain.com/page.php?<?php
Thanks for the help.
[/quote]
Hi,
I'm afraid my knowledge of php is pretty slim, but it looks to me like the menu links to the various examples on milonic.com pass the parameters as literals, like the Standard Demos menu shown below:
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.
Kevin
I'm afraid my knowledge of php is pretty slim, but it looks to me like the menu links to the various examples on milonic.com pass the parameters as literals, like the Standard Demos menu shown below:
Code: Select all
addmenu(menu=["m_standarddemos",,,210,1,"",style2,,"left",effect,,,,,,,,,,,,
,"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
])
Kevin
-
- Beginner
- Posts: 8
- Joined: Tue Nov 05, 2002 2:17 am
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...
Kevin
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...
Kevin
-
- Beginner
- Posts: 8
- Joined: Tue Nov 05, 2002 2:17 am
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:
domain.com/page.php?<?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.
domain.com/page.php?<?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.
-
- Beginner
- Posts: 8
- Joined: Tue Nov 05, 2002 2:17 am
PHP & MySQL
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)
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)