How To Keeping Textarea Content After A Form Submition With Jsp Not Duplicate?
I want to keep the textarea content in its filed after a form submition ... I work with jsp I try to do like this here solve to same problem but it not work with me my code : &l
Solution 1:
ok , the easy way :
in your servlet define :
Stringcomment= request.getParameter("preview-form-comment") ;
request.setAttribute("anydata", comment);
and in your textarea write :
<textarea id="preview-form-comment" name="preview-form-comment">${anydata}</textarea>
it run :) good luck
Solution 2:
One way to do this would be using php. I'll post an example below:
<inputtype="text"placeholder="Your name"name="name"value="<?phpif(isset($_POST['name'])){echo$_POST['name'];}?>">
I'm not sure if you know php or not but essentially here's the breakdown. From your html it looks like you're self submitting meaning returning to the same page. So when you post data to the page we can access it using $_POST['name of the field']
That said we can use the isset php method to see if the form has posted data and if it has populate the field with the old value.
Post a Comment for "How To Keeping Textarea Content After A Form Submition With Jsp Not Duplicate?"