A form loads and user enters their data. Form is submitted, with unrelated errors and the form page needs to be reloaded. I want to re-refill (re-populate) the Textarea with the user's prior comment data.
I figured out how to repopulate fields of type=text and type=checkbox. I don't see any way to pass data to the form to put into the textarea. Text & checkbox have value="" and "checked" which work.
Solution: the area between the textarea attributes and textarea close tag, is text that loads into the textarea as an initial value.
Here's the textarea options on 3wschools: https://www.w3schools.com/tags/tag_textarea.asp
I made a snippet. I can fill the address text field using value="Sunshine Lane". What can be used to pass to Textarea to fill it?
<form action="Online/DonateOnline.php" method="post" target="_self">
<label for "dcomments">Comments</label><span>
<textarea name="dcomments" id="dcomments" cols="100" rows="3"></textarea></span>
<br>
<br>
<!-- this text field works -->
<label for "address1">Address1*</label><span>
<input value="Sunshine Land"
name="address1" id="address1" type="address1" size="80" ></span>
<br>
<br>
<span>
<input type="submit" name="SubmitDForm" id="SubmitDForm" value="Continue" >
</span>
</form>
The only thing I see so far is to use ajax. But I don't know ajax & don't even know if it's set up on this system. Re-populating radio buttons and selection option in a form
Regarding the textarea to be repopulated, assuming that the snippet from the code is the php file,
then a tiny php addition, like this:
<?php isset($_POST['dcomments']) ? $dc = $_POST['dcomments'] : $dc = ''; ?>
<form action="Online/DonateOnline.php" method="post" target="_self">
<label for "dcomments">Comments</label><span>
<textarea name="dcomments" id="dcomments" cols="100" rows="3"><?php echo $dc; ?></textarea></span>
<!-- this text field works --> <label for "demail">Email*</label>
<span> <input value="something@test.org" name="demail" id="demail" type="email" size="80" ></span>
<br> <br> <span> <input type="submit" name="SubmitDForm" id="SubmitDForm" value="Continue" >
</span> </form>