0

I want to keep the textarea content in its filed after a form submition ... I work with jsp this is a simple sample for create form :

 <form class="form" id="preview-form"   action="textAreaData"  method="post">
 <textarea id="form-comment" name="form-comment"></textarea>
 <input type="submit" name="form=submit" id="form-submit" value="Submit"  >
 </form>

... How I can to do it ?

Micle
  • 87
  • 6
  • plz mr @BalusC your answer not work ... I reask this is my question after I read your answer can help me to knew why it not work ...... the link of new question :http://stackoverflow.com/questions/39189431/how-to-keeping-textarea-content-after-a-form-submition-with-jsp-not-duplicate/39189453#39189453 – Micle Aug 28 '16 at 15:28

1 Answers1

-1

I don't know much about the JSP but with JS or jquery we can achieve this by placing the text area values in the local storage. As soon as form was submitted we should place the textarea value again.

localstorage.FormComment=$("#form-comment").val();

We can retrieve following way

$("#form-comment").val(localstorage.FormComment);

Here I assumed your using JSP which is server side language so that your page will be refreshed on each request.

kernal_lora
  • 1,115
  • 3
  • 12
  • 25