• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 191
  • Last Modified:

Want to automatically save webform contenst anytime the user leaves the form...

Hi, I have a webform that consists of multiple pages.  I am running some .asp script to save the data to a MySQL Database when the user clicks a button on the bottom of the form.

However, I would like to trigger the form action so that the changes made are saved anytime the user navigates away from the page just in case they accidentally go to another page without clicking the button and lose all their data.

How do I do that?
0
MitchellVII
Asked:
MitchellVII
  • 6
  • 4
  • 2
1 Solution
 
Gurvinder Pal SinghCommented:
you can invoke the same method (you are invoking on button click event) on
onbeforeunload event of body tag

See the following page for reference
http://msdn.microsoft.com/en-us/library/ms536907(VS.85).aspx
http://reference.sitepoint.com/html/extended-event-attributes/onbeforeunload#
0
 
MitchellVIIAuthor Commented:
Thanks.

Ok, my current <form> looks like this:

<form method="post" id="DocEPW_IT_Demographic" action="scripts/asp/DocEPW_INSERT_IT_Demographic.asp" enctype="multipart/form-data">

and my button looks like this:

<input name="Submit" type="submit" class="button" value="Save and Continue!" tabindex=-1>

What exactly would I add to my body tag to make it run my .asp script on the "onbeforeunload" event?


0
 
Wayne BarronCommented:
That dialog box would drive me nuts, I could imagine what your visitors would do/think
If they had to put up with that box and its annoying noise, especially if you have a person
On your Form, that has his music turned up loud, that Dialog noise can take out your speakers.

You can do this using AJAX in what is called inline editing.
Once the user types in the information into a field it is automatically stored into the database.
I have been trying to work out the kinks in a demo code that I found, but have not had much luck at it yet.

You can view the demo here and if you have any luck or idea's in getting it to work properly
Please let me know.

http:Q_24976285.html ( InLine Editing using AJAX)

Carrzkiss
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
MitchellVIIAuthor Commented:
"That dialog box would drive me nuts, I could imagine what your visitors would do/think
If they had to put up with that box and its annoying noise, especially if you have a person
On your Form, that has his music turned up loud, that Dialog noise can take out your speakers."

Sorry, but what are you talking about?

My website doesn't have any dialog boxes that play music.  Also, I don't think I provided a link to my website in my post.
0
 
Wayne BarronCommented:
I take it you have not gone to the website provided be Mitchell?
http://msdn.microsoft.com/en-us/library/ms536907(VS.85).aspx

Check out the demo.
And it does not play music, you totally misread what what I wrote.

The link to the microsoft deal checks to see if you close the page, and if you do
It gives you a warning to let you know that you are trying to navigate away from the
Page, it is these types of things that most spam popup windows have.

Anyway, check out the link and you will see what I am referring too.

Carrzkiss
0
 
MitchellVIIAuthor Commented:
Ah ok, you were referring to the link provided by the other expert and not my website.  Ok, sorry.
0
 
Gurvinder Pal SinghCommented:
@MitchellVII: Did you tried the solution i suggested? Is it working fine for your requirements?

Thanks
0
 
MitchellVIIAuthor Commented:
qurv,

Thanks for asking.

I checked it but it is not working.  I am using the following:

<body lang=EN-US onLoad="elmLoop();disableAutoComplete('DocEPW_IT_Group')" onbeforeunload="document.forms[0].submit();">

<form method="post" id="DocEPW_IT_Group" action="scripts/asp/DocEPW_INSERT_IT_Group.asp" enctype="multipart/form-data">

But when the user navigates away from the page, the action is not firing as changes made are not being saved.
0
 
Gurvinder Pal SinghCommented:
"But when the user navigates away from the page, the action is not firing as changes made are not being saved."

Are you saying that
onbeforeunload="document.forms[0].submit();"
is not submitting the form?



0
 
MitchellVIIAuthor Commented:
correct, it is not.
0
 
MitchellVIIAuthor Commented:
ok, I'll try that.  Gimme a day or so.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 6
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now