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: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:18

Calling Javascript Function [solved]


Poster: umesh.awasthi
Dated: Saturday July 5 2008 - 18:06:49 BST

Hi All,

i am a begineer in javascript, basically a J2EE developer
so please don't mind if my question is out of track or a funny one

i am using the menu from the milonic team, it is being displayed in perfect manner, now i want that if the user click on any menu item or sub-meny item, i want to call a javascript function on the ONclick event and from there want to submitt the page.

for example in the usual manner
with(milonic=new menuname("About Us")){
style=submenuStyle;
aI("text=Product Purchasing Page;url=http://www.milonic.com/contactus.php;");
}
when the user click on the item "Product Purchasing Page" it will show up the http://www.milonic.com/contactus.php page
but i want that instaed of showing the page when the user click on the text with title "Product Purchasing Page" an onclick function will get called

so that i can set the action in the form nd submit the form

pleasetell me or suggest me how can i achieve that

thanks in advance
-umesh

Re: Calling Javascript Function


Poster: Ruth
Dated: Sunday July 6 2008 - 4:57:54 BST

Hi,

I'm not sure I understand what you want. Are you saying that when a person opens a submenu if they click on an item nothing happens for them but a form gets submitted to you? Wouldn't they wonder why they didn't go to any kind of page or something? Or do you want it to go to the page but also submit some kind of form to you?

You can set up the menu to submit things onclick. First you'd need a function for submitting. Then in your aI string you'd set up a clickfunction= and call that submit function. Something like this

Code:
aI("text=Submit Me!;clickfunction=submit_me()");


So, on click the menu would look for the submit_me function and do whatever that function is

Here is a post about using a submit function

viewtopic.php?f=10&t=9221&hilit=submit#p43770

Ruth

Re: Calling Javascript Function


Poster: umesh.awasthi
Dated: Sunday July 6 2008 - 5:44:06 BST

Thanks Ruth for the quick reply

i did what u mentioed in the post, actually my problem is that i have to use MVC2 model(Using Struts2) for the application so i can not take the user directly to anotherpage.

so what i have to do is that if the user click any option on the main menu or sub menu i have to call an appropriate action which will decide what page the user must be taken, thats why i was interested in onclick function so that i can setr the action from the onclick event and submitt the form to the appropriate action.

Regards
umesh

Re: Calling Javascript Function


Poster: Ruth
Dated: Sunday July 6 2008 - 7:47:22 BST

Hi,

So did that information allow you to do what you need?

Ruth

Re: Calling Javascript Function


Poster: umesh.awasthi
Dated: Monday July 7 2008 - 5:20:11 BST

yea it helped me to do what i was trying to do

thanks for the tip
:)

Re: Calling Javascript Function


Poster: Ruth
Dated: Monday July 7 2008 - 7:30:49 BST

You're very welcome. We aim to please :D

Ruth