Hi,
The following code I've wrote enables to identify modifications on page/form.
Enjoy it
code:
/**
* The following module enables to verify whether a page has been modified.
* In order to activate the module, call the _CapturePageState() function after the page loaded (last thing)
* and before submitting the page, you can verify if the page modified by calling the _isPageStateModified() function.
* Limitations: the module is not working well with dynamic content (adding removing content).
*/
var _objState = new Array();
function _CapturePageState(){
_objState = new Array();
var oElms = document.getElementsByTagName("*");
// Build a list of all the items and their values
for(var i=0; i<oElms.length; i++){
var o = oElms[i];
if(o.name && o.name.length > 0){
var item = o.name + "_" + o.value;
if(o.checked){
item += "_checked";
}
if(o.disabled){
item += "_disabled";
}
_objState[item] = "1";
}
}
}
// for checking a specific form, pass the form object as parameter
function _isPageStateModified(oBaseElem){
if(!oBaseElem) oBaseElem = document;
var oElms = oBaseElem.getElementsByTagName("*");
for(var i=0; i<oElms.length; i++){
var o = oElms[i];
if(o.name && o.name.length > 0){
var item = o.name + "_" + o.value;
if(o.checked){
item += "_checked";
}
if(o.disabled){
item += "_disabled";
}
if(!_objState[item]){
return true;
}
}
}
return false;
}
(Edited by Yossi Admon on 11-25-2004 14:16)
(Edited by Yossi Admon on 11-25-2004 14:34)