Solved

Save Form Date before reload

Posted on 2010-11-24
4
330 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

771 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

10 Experts available now in Live!

Get 1:1 Help Now