1

The default behavior of a textarea in a page when the user clicks in a link inside the page and then clicks the "back" button is to reset it's content. How can i prevent this?

Right now i have a PHP page with a textarea. The PHP script generates a small content and puts into the textarea, but if the user clicks in a link and then clicks the back button, the text doesn't appear anymore in the textarea.

ps.: Without using session, please.

What i'm actually doing:

page.php

<textarea readonly="readonly"><?php echo $somevarhere ?></textarea>
<a href="nicelink.php">Hey</a>

So, when i open page.php and click "Hey", i go to nicelink.php. If i press the back button, however, the content of the textarea is gone. I have to press F5 for the PHP to generate the page once again, and therefore the textarea content. How to prevent the textarea from being reset?

vinnylinux
  • 7,050
  • 13
  • 61
  • 127

2 Answers2

0

From what I understand, you don't want the visitor to change the TextArea. Maybe try setting it to read only?

Jacob
  • 2,769
  • 3
  • 21
  • 29
  • That's not exactly the question. The textarea is already readonly and it's contents are generated from my PHP script. I just don't want it to be reset when the user leaves the page and comes back. – vinnylinux Jun 07 '12 at 05:06
0

You could put the content of $somevarhere into a javascript variable and load it via ajax when $somevarhere is empty, transmit it via json etc. when loading the page or via event handlers.

Thats complicated but without sessions that should work...

Jurudocs
  • 8,595
  • 19
  • 64
  • 88