Calling Javascript Function [solved]

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
umesh.awasthi
Beginner
Beginner
Posts: 3
Joined: Sat Jul 05, 2008 5:58 pm

Calling Javascript Function [solved]

Post by umesh.awasthi »

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
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Re: Calling Javascript Function

Post by Ruth »

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: Select all

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
umesh.awasthi
Beginner
Beginner
Posts: 3
Joined: Sat Jul 05, 2008 5:58 pm

Re: Calling Javascript Function

Post by umesh.awasthi »

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
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Re: Calling Javascript Function

Post by Ruth »

Hi,

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

Ruth
umesh.awasthi
Beginner
Beginner
Posts: 3
Joined: Sat Jul 05, 2008 5:58 pm

Re: Calling Javascript Function

Post by umesh.awasthi »

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

thanks for the tip
:)
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Re: Calling Javascript Function

Post by Ruth »

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

Ruth
Post Reply