Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Three Submit buttons in the same row?

 
vaibhav punekar
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
I m invoking a servlet thro HTML submit button that outputs the detailed Reg form.It has three "submit" buttons in the end.Each has different action.I wish to place them in the same row of the table.How do I achieve this?
As far as I know there can be only one action.Shall I take three diff tables(1 row 1 column) having three forms resp. each having diff action.Right now they are placed one below the other.
Three common buttons are "submit" "back" and "cancel".
 
Ramneek Handa
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi vaibhav,
Just place the simple buttons instead of the submit buttons. Just call a function on onClick event of the button and pass the parameter 1,2 or 3 as action so that you can know which button is got pressed.
In the common function you can check which button got pressed and depending on that you can change the action and submit the form i.e
document.[formname].action="URL";
document.[formname].submit();
hope this will solve your problem.
bye.
 
vaibhav punekar
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ramneek,
I got your point,that means I ll have to use Javascript.
 
Melissa Jeidi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
couldnt you just have them all as submit buttons (only one will get pressed at a time.) and then check on the receiving page which one was pressed and do that action. then you dont need javascript.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please do not post the same message in multiple forums.
 
Mirko Froehlich
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would not recommend this, since there is no real need for using JavaScript here and it limits the clients that can use your page. Simply use three submit buttons with different name attributes (i.e. '...name="cancel"', '...name="update"', ...) and check for the existence of these names in your processing JSP or Servlet.
The other part of your question seems to be more of an HTML issue. I am not an expert on this myself, but it sounds like using a table row with three cells, one for each submit button, should work.
-Mirko
Originally posted by vaibhav punekar:
Thanks Ramneek,
I got your point,that means I ll have to use Javascript.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic