Solved

Save Form Date before reload

Posted on 2010-11-24
4
334 Views
Last Modified: 2012-05-10
i need a way to save the form data before the form is submitted or reloaded. I have a filter that opens in another window and thenrefeshes the form and then loose the data that is already entered.

My guess is to save each form element to a cookie. I dont know javascript so how is the best way to do this.

I need a code sample please.
0
Comment
Question by:garyilm
  • 2
  • 2
4 Comments
 
LVL 28

Accepted Solution

by:
sybe earned 500 total points
ID: 34205763
You can do it just by javascript. From the new window you can refer to the original window with: "this.opener.document". Then you can read the values entered in the form. No cookies needed (that would also be much more complicated and have some disadvantages).

That having said: why does the form need to be refreshed? I am quite sure that there is a simpler solution that will avoid the problem that you have.

0
 

Author Comment

by:garyilm
ID: 34205802
On my main page I have a form, one of the elements is a drop down. I then have a filter link that opens the child with the filter. Once the filter is set it closes and refreshes the parent.

0
 
LVL 28

Expert Comment

by:sybe
ID: 34205955
But you only need to change the options in the dropdown? You might want to use ajax to do that. That will leave the rest of the page untouched.

You could also write the filter in javascript in the page itself. Or you could have two connected dropdowns where the first picks the filter and the second shows the filtered options (that works only is the filter options are fixed, like dropdown1 = state and dropdown2 = city.

0
 

Author Comment

by:garyilm
ID: 34206003
Ajax would be the better option but I cant reinvent the wheel on this project.

From your first post I have this
<script langauge="javascript">
function post_value(){
  document.frm.c_name.value=opener.document.myForm1.location.value;

}
</script>

What is the code to set a cookie, something like this

 Cookie(namelocation)=opener.document.myForm1.location.value;

0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question