How to clear the form after submitting the values?

I have a form with several submitted. As soon as I submit the form, the data will be saved in the database and I will return to the same page. Now how to clear the fields in the form?

This is a location based app. When submitted, it performs some checks using a java script, then redirects to the same page. Now I have to get a new page. I mean, the fields must be cleared.

+3
source share
6 answers

You can override Struts' action method reset(), and after you use it in your action, you can do form.reset(request, response);and redirect. Thus, your form is reset.

+2

javascript reset() ?

0

2 JavaScript form.reset() formclass , reset struts .

0

reset .

0

:

request.setStatus(request.SC_SEE_OTHER);
request.setHeader("Location",url);

SC_SEE_OTHER - 303, "url" - URL- , , reset.

0

In my case, I am processing the java action class, you must clear the model or bean in your java class before returning Action.SUCCESS; example customerDetail.setId (""); customerDetail.setName ("");

0
source

All Articles