0

I have asked a similar question in the past but would like to know if it's possible to link the "textarea" content between the pages as I have thought that this might be a better solution.

I'm new to coding and unfortunately I don't have a good understanding of how to do it on my own.

Any help would be appreciated. I'm not sure if it's even possible.

Page 1
$linked text = 
This is the text which
Should be displayed on the second page.
And should be updated automatically
Once I update this text on page 1.



Page 2
<div class="textniz">
<textarea class="two" id="myInput" name="myInput" readonly>
$linked text</textarea>
</div>
tgdavies
  • 10,307
  • 4
  • 35
  • 40
Edvard
  • 163
  • 8
  • do you open page 2 from a link in page 1 ? If yes , insert that content into the url, so you can get it . If not, look at localstorage or sessions but it will be avalaible from that user. However, clarify your question about your real case and use. – G-Cyrillus Jul 24 '21 at 09:50
  • however looks like you had a few answers here https://stackoverflow.com/questions/68465388/link-text-to-another-page What's wrong or new ? – G-Cyrillus Jul 24 '21 at 09:56
  • The difference is that in this example I need to change "textarea" instead of

    . Or it won't make any difference at all?

    – Edvard Jul 24 '21 at 10:04
  • I have just tried the options were sent to me, I'm not sure if they work or at least I wasn't able to complete the steps. Maybe anyone can assist here? I have tried to make the question as short and as clear as possible. – Edvard Jul 24 '21 at 14:49

1 Answers1

1

It would be nice to know more about your webserver. Sticking to the KISS principle, and using a PHP server as an example, this could be accomplished with POST and an html form like the following:
page1:

<form action="/page2.php" id="usrform">
  <input type="submit">
</form>
<textarea name="comment" form="usrform">Enter linked text here...</textarea>

Then with page2.php:

<html>
<body>

<div class="textniz">
 <textarea class="two" id="myInput" name="myInput" readonly>
  <?php echo $_POST["comment"]; ?><!--This is where page 1 data is retrieved-->
 </textarea>
</div>

</body>
</html>

The above will only update page 2 when the user clicks the submit button. For the automatic aspect you could use AJAX JS to send the updated data on each key change. You can take a look at this simple example.

I used PHP for illustrative purposes. The concept you want to implement is really about submitting and retrieving a POST request containing the linked text and is supported by all webserver types. JavaScript will help you accomplish the automatic part.

Brian
  • 198
  • 1
  • 1
  • 8