0

Related to this question: Keep values selected after form submission

I have a form with some inputs, and a Textarea field.

Well, the form works perfectly after submit the form, I get back all parameters in its respective inputs. But if the Textarea contains text with intros, for example:

Lorem ipsum, dolor sit ametLorem ipsum,
dolor sit ametLorem ipsum, dolor sit am
etLorem ipsum, dolor sit ametLorem ipsu
m, dolor sit ametLorem.

Lorem ipsum, dolor sit amet

The form after sending appears in blank, without any refilled input.

Here is the code

<form id="frm1" name="frm1" method="POST">
<table><tr><td>
<textarea name="txt_area" id="txt_area"cols="45" rows="5"></textarea>
</td>
</tr><tr>
<td><input type="text" size="40" name="name" id="name" />
</td></tr></table></form>

<script type="text/javascript">
document.getElementById("name").value = "'.$_GET["name"].'";
document.getElementById("txt_area").value = "'.$_GET["txt_area"].'";
</script>
Community
  • 1
  • 1
Alex Deiwor
  • 117
  • 3
  • 9

1 Answers1

1

I think that you are using php
try this:

document.getElementById("name").value = "<?php echo($_GET['name']); ?>";
document.getElementById("txt_area").value = "<?php echo($_GET['txt_area']); ?>";

instead of this:

document.getElementById("name").value = "'.$_GET["name"].'";
document.getElementById("txt_area").value = "'.$_GET["txt_area"].'";
Alessandro Minoccheri
  • 35,521
  • 22
  • 122
  • 171