Tags: form, input, javascript, php, programming, refresh, reload, via

Keep form input after a refresh/reload

On Programmer » PHP

3,089 words with 5 Comments; publish: Fri, 16 Nov 2007 00:25:00 GMT; (200171.88, « »)

I am not sure if I should do this via JavaScript or PHP, but I am going to give this forum a try to see if I can get help on this problem.

I have this form, whose page will be reloaded to add new values to its drop down menu via php from a mysql database. In order to pull the newly added values, this page needs to be reloaded.

I want the user to keep all the data they have written thus far after the reload.

I need a script that will allow to store those values temporarily (without a submit) so that the user need not type them again.

Example:

I have a form with 12 fields to fill out. Above 5 of those fields (all drop down boxes) is an "add new item" option. This will allow the user to add the new item if it is not in the database, the next time the page is loaded the dropdown box will contain the new item.

The problem is that I want to keep all the previous user selections/input up to this point.

I could get around this problem if there was a way to "refresh" just the specific drop down box, but I doubt that is possible.

hope someone can help..

thanks

All Comments

Leave a comment...

  • 5 Comments
    • I'm not sure if this will help you, but I'll give it a try

      In Mozilla Firefoc, I have a page with five select boxes (all with the same choices). I open a second tab in wich I add another choice to select. Now if i refresh the first tab (with select boxes) all the choices up till now are saved automatically. I don't know how it behave's in IE though.

      #1; Thu, 15 Nov 2007 22:08:00 GMT
    • After searching the web for more ideas on how to solve this issue, I am beginning to think that using an "onClick" function on the links within that page may be the way to go.

      In that case, I had no luck finding something of that nature either...

      I need an onClick function that will store all the values that are being used in the form until this point, so that the next time this page is loaded, I can repopulate the form with these values.

      Any help would be greatly appreciated.

      #2; Thu, 15 Nov 2007 22:09:00 GMT
    • Thanks Wilku,

      The form includes numerous input text fields as well.

      I have tested it on safari, firefox and IE. Neither of which stored form info after a refresh/reload. It just returns a clean page.

      #3; Thu, 15 Nov 2007 22:10:00 GMT
    • Anyone have an idea?
      #4; Thu, 15 Nov 2007 22:11:00 GMT
    • If you say relaod, I assume you are submitting the form?

      Then the most standard way to do this is to echo out the posted values into the form.

      $short = secure_content($_POST[short]);

      $menulabel = secure_content($_POST[label]);

      <textarea class=\"formel_2\" name=\"short\" cols=85 rows=2 class=\"formel\">$short</textarea>

      $menublock

      $folderblock

      $menusectionblock

      <hr>

      <input class=\"formel_1\" type=\"text\" value=\"$menulabel\" name=\"label\" size=30 class=\"formel\">

      Note the function I throw over the $_POST variable before retrieving them It is a function I wrote for myself to secure userinput. Have a look at the predefined function html_encode() for more info.

      J.

      #5; Thu, 15 Nov 2007 22:12:00 GMT