How to transfer parameter url in function of the menu?

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
AlexDulub
Beginner
Beginner
Posts: 6
Joined: Sun Feb 22, 2004 3:20 pm

How to transfer parameter url in function of the menu?

Post by AlexDulub »

The user chooses something on a page and according to it should be formed url. Here at me a question. How to transfer parameter url in function of the menu?

Something like this :

.html:
popup('milonic','menu','my parameter')

.js:
aI("text=Enter;url=and here I want my parameter");

or better so:
aI("text=Enter;url=index.php?" + and here I want my parameter");

As to me it to make? It is possible?[/i]
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

Hi Alex,

If I understand:

html: You cannot pass a url to trhe popup() function. popup() is only for opening a menu and has nothing to do with URLs.

js: Pass a URL exactly as you would in any other link, like so:

Code: Select all

aI("text=Enter;url=index.php?location=1;");
Since all of the argument to the aI() funciton is a string, you could also pass parameters through string manipulations, like this:

Code: Select all

loc = 1;
paramStr = "location" + loc + ";";
.
.
.
aI("text=Enter;url=index.php"+paramStr+"status=go to new location;[i]...other properties as needed...[/i];");
Hope that helps,

Kevin
AlexDulub
Beginner
Beginner
Posts: 6
Joined: Sun Feb 22, 2004 3:20 pm

Post by AlexDulub »

Many thanks for this answer. There is at me another question. How in menu.htm keep some parameter, what I then could take away it from menudata.js? Something like this:

.html:
function SaveParameter(page) {
var some_parameter = page;
popup('milonic','Milonic')
}

.js:
aI("text=Enter;url=index.php"+some_parameter");
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

Sorry... but I do not understand the question.

Kevin
AlexDulub
Beginner
Beginner
Posts: 6
Joined: Sun Feb 22, 2004 3:20 pm

Post by AlexDulub »

I'm from Russia and my english not well(sorry for this). I try to explain. I want to keep some parameter. Couse I don't know what user will choose. For example: User choose on the page(menu.html) something and after that I must redirect user to 'menu.html?parameter=something'(using your menu...). Here I have a problem how to transfer this parameter something in menu_data.js.

I want to make so :
aI("text=Enter;url=menu.php?parameter="+something);

Alex Dulub.
[/i]
User avatar
Maz
Milonic God
Milonic God
Posts: 1717
Joined: Fri Jun 06, 2003 11:39 pm
Location: San Francisco
Contact:

Post by Maz »

Sounds a bit like where I left off, its probably a server side configuration or what ever you call them.

Lets see if its the same thing, so I would click on a menu link to type=1, where I get a selection of links, I click one and the url goes to id=1 of type 1. But it no longer is an active page on the menu.

In my case it would be nice to still register as an active page within type 1, I'm not sure how he's trying to use it. But I had thought of making a menu item appear for that area.

If type=1 showmenu id=all

Am I close?

maz
AlexDulub
Beginner
Beginner
Posts: 6
Joined: Sun Feb 22, 2004 3:20 pm

Post by AlexDulub »

I know how to explain. On page menu.htm at me a chessboard. The user clicks for example on e4 and at him jumps out the menu, that it wants to make (to resemble, make a check, to bring down a figure...) Here I also should be sent coordinates of his course on other page what to process it there (whether whether to check up it is possible so to resemble, check up is mat, etc.) At once I do not know where the player will press (therefore it is necessary to send parameter).
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

Hi Alex,

Your English is much better than my Russian!

I am still not sure that I understand completely, but I will try to answer what I think you are asking.

(1) In your menu_data.js file, at the top, you could define the variable, something, which will be used to store the result of a user clicking on one of the links in the .html page. You would also define a function, called setSomething(), to set the value of the variable something. Like this:

Code: Select all

var something;

function setSomething(value)
{
  something = value;
}
(2) In your .html document you could have links like this:

Code: Select all

<a href="javascript:setSomething('e4')">link text or image</a>
<a href="javascript:setSomething('e5')">link text or image</a>
Each of the links, when clicked, calls the setSomething() function and passes a value to set the something variable to.

(3) Your menu item could then pass the current value of something in its URL, like this:

Code: Select all

aI("text=Enter;url=menu.php?parameter="+something+";");
I hope that helps,

Kevin

P.S. Maz -- I still don't understand your goal. :? Sorry.
AlexDulub
Beginner
Beginner
Posts: 6
Joined: Sun Feb 22, 2004 3:20 pm

Post by AlexDulub »

Hello ,

Many many thanks for your reply. But programm don't still work. I have an error with on undefined value. I made programm according with your instructions.

in .html file I have function:

function Save_parameter(parameter);
{
link = parameter;
popup('milonic','Milonic');
}

...
onmousedown=Save_parameter('<? echo $i$j ?>')
...

.js file:

aI("text=Take current position; "url=index.php?parameter="+link+";");

And IE show me that link is undefind.

Please accept my thanks in advance.

Alex Dulub
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

Hello Alex,

This is only a guess since I cannot see your entire page, but I think that your link variable may not be global.

Is link declared anywhere outside of the Save_parameter() function? In my previous example, you will notice that the variable, something, is declared outside of the setSomething() function, like this:

Code: Select all

var something; 

function setSomething(value) 
{ 
  something = value; 
}
Declaring the variable outside of the function make's it global in scope, so that its value can be accessed in multiple functions on the page. In your case, if link exists only inside of the Save_parameter() function, then its value is accessible only inside of that function, and it therefore has no value... it does not exist... outside of that function. To make a variable global, declare it outside of a function definition, like this:

Code: Select all

var link;  // this declaration makes it global

function Save_parameter(parameter); 
{ 
link = parameter; 
popup('milonic','Milonic'); 
} 
I hope that helps,

Kevin
AlexDulub
Beginner
Beginner
Posts: 6
Joined: Sun Feb 22, 2004 3:20 pm

Post by AlexDulub »

Hello Kevin,

Thanks for reply. But I still have a problem.

When I do so, the menu is not shown.

html:
<SCRIPT language=JavaScript>
var url;
function leavePage(page) {
url = page;
popup('milonic','Milonic')
}
</SCRIPT>

js:
with(milonic=new menuname("Milonic")){
style=menuStyle;
aI("text=Enter;url=index.php"+url+";");
}

or so
js:
with(milonic=new menuname("Milonic")){
style=menuStyle;
aI("text=Enter;url=index.php"+url);
}



When I clean "+url" that all is perfectly shown. Like this:

js:
with(milonic=new menuname("Milonic")){
style=menuStyle;
aI("text=Enter;url=index.php");
}


Please accept my thanks in advance.

Alex Dulub
Post Reply