retain form values
- Started
- Last post
- 7 Responses
- kinetic
hey, i feel this should be something that is easy to do, but i'm really not sure how :/
if i fill out an html form, submit and there is an error, when i go back all the data is lost (im submitting to php by the way)
i noticed some forms retain the data..how is this done? with sessions? there's gotta be an easier way
i tried js.back() function, no dice...still kills the previously entered data on return to the form
- Rand0
.
- oBeseLilNinja0
im not a php programmer but are you clearing the cache or buffer in the code
like in asp (im not a asp coder either :P) the code
response.buffer =false
response.expires = -1000most likely clears the values when the page is rehit
if your not using the browser history.back() and are using a seperate back button on your page you code post the data to the page via the form
- welded0
There might be a more elegant way, but if you just echo the form data as the input value then it'll show up.
- welded0
Hm, upon review I could be a little more clear, but that should be enough to point you in the direction you need to go.
- heavyt0
i think that the POST data still exists, so you can add to your form:
if(isset($_POST['name'])) {this.value = $_POST['name']}and that should hold them.
- root_lock0
if your talking on a development stand point and you dont want to reput data after errors are thrown use firefox, it will retain the previous data, also get the web developer toolbar which has a populate form fields, which fills the form fields with the name of the text box, field etc.
if your talking on the client level after validation and you want to retain data, submit the form to the same page the form is in .. with logic like.
if form.submit ="submit" then
then set form fields to variables, and echo the variables to the textbox.
- kinetic0
yea, i figured id have to write them back into the value parameters of the fields with php
kind of a hassle...was hoping there was some easier way to do it
ahwell
thanks :)