jQuery in Action, 3rd edition
The moose likes HTML, CSS and JavaScript and the fly likes Verfiy/ Preview form data before submitting. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Verfiy/ Preview form data before submitting." Watch "Verfiy/ Preview form data before submitting." New topic

Verfiy/ Preview form data before submitting.

Karthik Muthukumaraswamy

Joined: Oct 30, 2006
Posts: 12
I want to implement a functionality where a user is shown all the form data he recently entered before he decides to submit/edit it.

Something like this:
enter data -> preview -> submit/edit

ps: I am using JSP and struts.
Thank you.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

Anything that transpires prior to submission must be done with JavaScript.

[Asking smart questions] [About Bear] [Books by Bear]
Joel Jorgensen

Joined: Oct 13, 2006
Posts: 22
There are two ways that I can think of that you would be able to do this. The first way, as Bear mentioned, would be to use JavaScript to validate the form data and rearrange the page to provide a preview of what the user would be submitting. Put a "preview" button on the form and have it call a JavaScript function to do the validation/rearrangement, and then provide Submit and Edit buttons which will either submit the page or return it to it's previous (editable!) form, respectively.

The other way to do it would involve sending it to the server, Struts would do the validation (the details of which elude me as yet) and return either success (in the form of a preview JSP which takes the values from the form and displays them the way they'll be submitted) or failure (probably the original form, with the erroneous parts somehow highlighted for easy repair). The preview page would also provide a button for the user to confirm/submit the data, and a button for the user to edit the data, and each would be mapped to their appropriate Struts Actions (though if you want more details on how to do it that way, the proper place for it would probably be the Struts forum).

Go is to the fountain.
I agree. Here's the link: http://aspose.com/file-tools
subject: Verfiy/ Preview form data before submitting.
It's not a secret anymore!