Jump to content

Preserving values in input field after page gets refreshed


eldan88

Recommended Posts

 

I wanted to know if there is a way to keep text in the input fields if a user hit the refresh button while typing something in a form.

As an example how would I keep the users name in a text field, if they type it in the name text field and hits the refresh button. Below is the code Im trying to use as an example..

 

<td width="232"><input type="text" id="name" name="name"  value="<?=$name?>" /></td>

 

 

 

 

Thanks!

 

I thought browsers did this already? At least, Firefox 13 does.

 

Your example code would work if they submit the form (and if you assign $name to the POST variable), but not on a page refresh. I'm not sure if there is an elegant solution for doing it on page refresh if the browser doesn't do it for you. The only thing that springs to mind is using Javascript to put the form data into a cookie or a PHP session - but neither of those sound like good ideas.

Can I ask Why you want to do this? I really hate that Firefox refuses to clear out my fields when I refresh a page. If I refresh a page, I expect a pristine new copy of the page, that's why I hit REFRESH.

 

When I am testing a form and having trouble with some JS / AJAX / PHP, and I make some code changes and hit REFRESH, it doesn't clear out the form and I have to find some other way to force it to reload the page. I guess, I expect a refresh to be a reload.

 

Am I the only one who thinks like this?

Can I ask Why you want to do this? I really hate that Firefox refuses to clear out my fields when I refresh a page. If I refresh a page, I expect a pristine new copy of the page, that's why I hit REFRESH.

 

When I am testing a form and having trouble with some JS / AJAX / PHP, and I make some code changes and hit REFRESH, it doesn't clear out the form and I have to find some other way to force it to reload the page. I guess, I expect a refresh to be a reload.

 

Am I the only one who thinks like this?

 

Eh, I don't find it to be a big deal. I've trained my hands to go for F5 and ctrl+F5 (reload the cache, thus clearing the form fields) instead of the refresh icon.

Eh, I don't find it to be a big deal.

 

actually it is.

 

I wanted to know if there is a way to keep text in the input fields if a user hit the refresh button while typing something in a form.

 

define "refresh".  This is totally client browser issue.  or is it?  can the server 'refresh' my client browser?

 

typing 'what'? in what 'form'?

 

login yahoo mail, look at no one sends me email.  When I click client browser 'refresh' button, what happens?

 

Wait, what if I open multi tabs/winders on yahoo mail... any tab/winder, When I click client browser 'refresh' button, what happens?

 

Wait, login compuserve, login AOL, open a safari winder?

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.