aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes How to give multiple actions in a single form? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to give multiple actions in a single form?" Watch "How to give multiple actions in a single form?" New topic
Author

How to give multiple actions in a single form?

Azam Khalidi
Greenhorn

Joined: Oct 04, 2007
Posts: 2
This is the HTML file with two buttons on it, I want to transfer control to different servlets on the button clicks, but when I press the buttons the onclick() event doesn't seem to work. Is there any other way to assign multiple actions to a single form?

input type = "submit" name = "click1" onklick = gotoServlet1();
input type = "submit name = "click2" onklick = gotoServlet2();

gotoServlet1 and gotoServlet2 are javascript functions

function gotoservlet1(){
document.form.action = "./servlet1";
document.form.submit;
}

function gotoservlet2(){
document.form.action = "./servlet2";
document.form.submit;
}



This is not working, pls advice me...
Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61652
    
  67

Please use real words when posting to the forums. Abbreviations such as "pls" in place of "please" only serve to make your posts more difficult to read and less likely to generate useful responses.

Please read this for more information.

thanks,
bear
JavaRanch sheriff


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61652
    
  67

It's hard to tell from your code (please use UBB code tags when posting code, read this for more information), but it looks like your HTML is invalid. Please be sure to quote the values of all attributes, inlcuding those for onclick.
[ October 18, 2007: Message edited by: Bear Bibeault ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

document.form.submit;


Also, submit is a function.
To call it, you need to add a set of empty parenthesis.

I'm going to move this to our HTML/Javascript forum since all the code in question is interpreted on the client machine.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
 
subject: How to give multiple actions in a single form?