aspose file tools*
The moose likes Servlets and the fly likes Onclick form submission Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Onclick form submission" Watch "Onclick form submission" New topic
Author

Onclick form submission

vaibhav punekar
Ranch Hand

Joined: Jan 20, 2001
Posts: 134
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.


VAIBHAV <BR>SCJP
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

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.


SCJP
Visit my download page
Ajan Balakrishnan
Ranch Hand

Joined: Jan 04, 2001
Posts: 71
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

Joined: Aug 20, 2012
Posts: 2
correction : it should be

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

in the servlet
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61658
    
  67

altanai bisht, we appreciate you wanting to help, but this post is 11 years old! Please focus on more modern posts.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
 
subject: Onclick form submission