Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to give multiple actions in a single form?

 
Azam Khalidi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic