He, I've got an html textarea in my php code with an initial value "enter description here..." The problem is when the user leaves the page and clicks the back button instead of the initial value the text area has what was previously written in it as a value. How can I make the browser forget these values as soon as you leave the page? I was able to do this with the text boxes in the form by adding autocomplete="off" to the form tag but that doesn't seem to be workign for the text area (and yes I did also try adding autocomplete="off" to the textarea tag too).
Any help is much appreciated,
-Ryan
Clear Textarea on Back Button>
Moderator: General Moderators
Re: Clear Textarea on Back Button>
The simplest thing is to change it to "enter description below."
You could maybe do something hackish like an javascript window.onunload function that clears the box.
You could maybe do something hackish like an javascript window.onunload function that clears the box.
Re: Clear Textarea on Back Button>
How would such a javascript work?
Re: Clear Textarea on Back Button>
Code: Select all
window.onunload = function() {
// get a reference to the textarea by using getElementById
// set the element's value property
}Re: Clear Textarea on Back Button>
Most solid way is to load the default value into it when the page loads
Code: Select all
<input type="text" id="mybox" />
<script type="text/javascript">document.getElementById('mybox').value='Some default value';</script>