Losing form data when page refreshes

I am really hopeing this is a easy question.  I have a form that they fill out some fields, and when a user clicks on a product it opens a popup window to drill down to what they want.  The only problem is when they close the pop up, I have it refreshing the page to show the new information, but it loses all the information typed in to the form fields, and they have to retype the information.  Is there a way to keep the information, so when the page refreshes it will still be there.  Any ideas?
LVL 3
MepsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mrichmonCommented:
No.

You cannot refresh a form using refresh and keep the form data.

You can however have the page submit and thereby get the new data, but also put back any info that was typed into the form so far.

But the disadvantages here are that if they then manually hit refresh they get the "you posted info - are you sure you want to re-post" message.
mrichmonCommented:
I just thought of another option.

Don't refresh or reload at all.  Have the close of the pop-up dynamically change the main form by using javascript.

Then it looks like it was refreshed, but in actuality wasn't.

This is more complex than a  refresh but you save all the user data.
MepsAuthor Commented:
Would it be possible to use Javascript the other way, that when the user clicks on the link and the popup comes up that it saves the data in the form.  It is only a single form field that I wanted the data to be saved on.
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

mrichmonCommented:
Oh if only a single form field then that is a lot easier and you have more options.

For example, have the link to open the pop-up also write the form field to a hidden value in the pop-up.

Then the close, does the refresh and then write back the value to the form field.
marcin_komCommented:
Hehe.... I'll brag about Firefox here - unlike Internet Explorer, Firefox does remember what you entered in a form when you refresh the page.... ;)

But seriously now.... here is another way to do this, which would handle complex forms and multiple fields.

Open the popup as a submission of the form you are in.  This can be done with JavaScript- you open a poup using window.open(), than change the target of your form to be the popped up window and submit.  This will give you a chance to save the current values of the form into session variables.

When the popup closes and reloads your original form, you can repopulate it using what you have saved in your session variables.

Question - why do you reload the original window on the close of the popup?

Marcin
mrichmonCommented:
>>unlike Internet Explorer, Firefox does remember what you entered in a form when you refresh the page
Not if you do a full refresh (also called a force or hard refresh).

Both browsers are beginning to support soft and hard refreshes.  Ones initiated by javascript are often considered hard refresh.
MepsAuthor Commented:
I reload the original window to show the new selections.

I am not very good with Javascript, check this for me
<SCRIPT LANGUAGE="JavaScript">
var case_num= opener.form.CASE_NUM.value
</SCRIPT>

How do you pull out the Javascript value case_num into a session variable?
mrichmonCommented:
You can't.

Session are server.  Javascript is client.

But you can just store it in a javascript variable on the child page and then write back to the parent page using javascript again.
MepsAuthor Commented:
Ok, how do you pull out the variable? and write it to the parent page.  I tried opener.form.CASE_NUM.value=case_num

Example Turn it into a URL variable.  .cfm?case_num=Javascript case_num
mrichmonCommented:
is the parent named opener?

Basically you could do what you are thinking, but not from the URL, instead from a javascript variable in the pop-up

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MepsAuthor Commented:
I almost have it working, the only problem is I get an error when I take out the alert box.

var case_num= opener.form.CASE_NUM.value

function clos(){
opener.window.location.reload();
alert(case_num);
opener.form.CASE_NUM.value=case_num;
}

I don't know if the alert box cause enough of a delay for the parent form to open, is there a way to add a slight delay, or check to make sure the page is loaded before it tries to input the data.  Yea, opener is the parent.  I think I got that off some book.
MepsAuthor Commented:
Fixed it, Thanks everyone.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.