• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to give multiple actions in a single form?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic