Solved

Save Form Date before reload

Posted on 2010-11-24
4
331 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP CDO - Limiting Connections 2 39
Angular- typeahead works but need to change 2 things 5 17
Recordset containing single quotes 8 22
Objects on Same Line 2 18
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
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 basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now