Scenario: A user is filling in a form and accidentally browses back.
Is there a way to use cache or something of the sort so that the user can just hit forward and the form values they were just filling out are not lost? Or not use cache at all and if the user hits the delete key or backspace key it will pull up a javascript prompt asking if they are sure they want to do that, if so what javascript command is used to detect this?
Keeping Form Values
Moderator: General Moderators
Re: Keeping Form Values
ive had this problem before
It might go something like this:
etc.
Note: for the drop down list, you have to specify the if statement on each option value.
This might not be exactly what youre looking for but i think it should help a little.
Granted the user submits the form.
It might go something like this:
Code: Select all
<form>
<input type="text" name="random" value="<?php echo $_POST['random']; ?>">
<select name="state">
<option value="XX" <?php if($_POST['state'] == "XX") echo "selected"; ?>>XX</option>
</select>
</form>
Note: for the drop down list, you have to specify the if statement on each option value.
This might not be exactly what youre looking for but i think it should help a little.
Granted the user submits the form.
Last edited by remyx187 on Fri May 02, 2008 12:00 pm, edited 2 times in total.
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: Keeping Form Values
but if they hit the back button without "posting" any values then the values will never exist!
Re: Keeping Form Values
The only thing that comes to mind is using javascript with onchange so that you DO keep the data in a cookie as soon as they type
Re: Keeping Form Values
Any other ideas?
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: Keeping Form Values
You can't retrieve data that hasn't been posted.
Re: Keeping Form Values
Javascript? Cookie? Cache? Errm...
It's the default behaviour of a web browser
User types something in form...
User clicks back button by mistake...
OOPS! User clicks forward again...
The form values are restored
No scripting required.
It's the default behaviour of a web browser
User types something in form...
User clicks back button by mistake...
OOPS! User clicks forward again...
The form values are restored
No scripting required.