Advertisement

07.10.2008 at 08:16AM PDT, ID: 23554098 | Points: 500
[x]
Attachment Details

Attach change event to all html elements in the form

Asked by jagadeesh_motamarri in JavaScript, Web Languages/Standards

Hi Experts,

I'm trying to experiment with the same old known window.onbeforeunload event to prompt the user to save the data before he navigates away from the current page.

i found couple of ways but none of them really fit into my application design where some of the form data is loading using AJAX,, DOM, Javascript, scriplets etc. So the best method i found (of course, at the cost performance hit) is to attach a change event to all the html elements and set a flag if a certain element is changed and when navigating away of the flag is set just prompt the user to save first.

Here is sample code that i've using jquery that triggers changes within radio and checkboxes ....can someone help me to put the same for multi-select lists, dropdown, textarea, rich textareas etc?
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
$(document).ready(function() {
 
// check if any radio button value is changed
$("input[@type='radio']").bind("change", function() { alert ("Some radio value is changed"); }); 
 
// check if any checkbox value is changed
$("input[@type='checkbox']").bind("change", function() { alert ("Some checkbox value is changed"); }); 
 
});
[+][-]07.10.2008 at 10:05AM PDT, ID: 21975489

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 11:29AM PDT, ID: 21976161

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 11:31AM PDT, ID: 21976174

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 12:56PM PDT, ID: 21976818

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 03:16PM PDT, ID: 21977838

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628