Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Onclick form submission

 
vaibhav punekar
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I ve been the victim of Javascript these days.I was trying to submit my form generated thro servlet .My form contains three buttons SUBMIT BACK CANCEL.so i m not able to use input type =SUBMIT that does not allow three buttons in a single row.So i used javascript onClick=somefn that submits the form finally by document.myform.submit().It many times gave error of object expected so I used \"parent.location=../../nextservlet.It worked fine but could not receive values thro req.getParameter().It gave NULL values.
so Does parent.location not submit the form actually?
What is the best soln for this?PLEASE START THE LIST ABOUT THE
POSSIBLE ERROR CASES OF JAVASRIPT(object expected)AND POSSIBLE SOLNS FOR IT.please.
 
Randall Twede
Ranch Hand
Posts: 4363
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stay away from javascript as much as possible. you can have a "submit" and a "cancel" in straight html but "back" will need a button with a onclick(i think). You can use multiple submits if you uses seperate forms for them(worth thinking about).
Anyway since I cant solve your problem outright I thought I would give you my advice. Use script as a last resort. There is too much browser incompatibility and possible script errors for me to like it.
 
Ajan Balakrishnan
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think parent.location submits the form. What you need to do here is have all the 3 buttons as type SUBMIT with same name and different values and inside your servlet get the value see which button is pressed. Take a look at the follwoing example.


Alternate way to have a cancel button, as Randell mentioned earlier, have them as type cancel so as to avoid further checking at the server side.
Let me know if this helps
Ajan

[This message has been edited by Ajan Balakrishnan (edited February 17, 2001).]
 
altanai bisht
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
correction : it should be

String buttonval= request.getParameter("submit");

in the servlet
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
altanai bisht, we appreciate you wanting to help, but this post is 11 years old! Please focus on more modern posts.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic