如何检查表单是否已更改 [英] How to check that a form has been changed

查看:77
本文介绍了如何检查表单是否已更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


如何检测表单元素是否已更改?这个帖子:

http://groups.google.com/group/comp .... 5a82c9be127790


建议您将onChange事件处理程序附加到每个表单元素,

以及处理程序触发时更新全局''isChanged''变量。

这个技术对我来说似乎有点乱(我有很多形式

元素),我在考虑存储原始表单对象在一个

javascript变量当身体加载时(在bodie的onLoad事件中

处理程序)和upons提交,进行javascript平等比较

与当前表单对象。如果没有任何改变,那么两个

对象应该相等,对吧?


if(oldObject == document.getElementById(''form'') )

{

提醒(''已更改!'');

}


这会有用吗?


干杯


Taras

Hi everyone,

How do you detect that a form element has been changed? This thread:

http://groups.google.com/group/comp....5a82c9be127790

suggests that you attach onChange event handlers to every form element,
and when the handler fires you update a global ''isChanged'' variable.
This technique seems to be a bit messy to me (I have many form
elements), I was thinking about storing the original form object in a
javascript variable when the body loads (in the bodie''s onLoad event
handler), and upons submission, doing a javascript equality comparison
with the current form object. If nothing has changed, then the two
objects should be equal, right?

if(oldObject == document.getElementById(''form''))
{
alert(''has changed!'');
}

Would this work?

Cheers

Taras

推荐答案

Taras_96于2006年4月30日在comp.lang.javascript中写道
Taras_96 wrote on 30 apr 2006 in comp.lang.javascript:
如何检测表单元素是否已被更改?这个帖子:
[..] if(oldObject == document.getElementById(''form''))


永远不会通过表格来识别表格,顺便说一句

{
警报(''已更改!'');
}

这会有用吗?
How do you detect that a form element has been changed? This thread: [..] if(oldObject == document.getElementById(''form''))
never ID a form by "form", btw
{
alert(''has changed!'');
}

Would this work?




你检查了吗?


-

Evertjan。

荷兰。

(请将x''es更改为我的电子邮件地址中的点数)



Did you check?

--
Evertjan.
The Netherlands.
(Please change the x''es to dots in my emailaddress)


" Evertjan。 <前************** @ interxnl.net>写道:
"Evertjan." <ex**************@interxnl.net> writes:
永远不会通过表格识别表格,顺便说一句
never ID a form by "form", btw




你能否证明它失败的情况?我看不出有任何问题。


/ L

-

Lasse Reichstein Nielsen - lr*@hotpop.com

DHTML死亡颜色:< URL:http://www.infimum.dk/HTML/ rasterTriangleDOM.html>

''没有判断的信仰只会降低神灵的精神。''



Can you show a case where it fails? I can''t see any problem with it.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
''Faith without judgement merely degrades the spirit divine.''


Lasse Reichstein Nielsen在4/30上说了以下内容/ 2006 5:43 AM:
Lasse Reichstein Nielsen said the following on 4/30/2006 5:43 AM:
Evertjan。 <前************** @ interxnl.net>写道:
"Evertjan." <ex**************@interxnl.net> writes:
永远不会通过表格来识别表格,顺便说一下
never ID a form by "form", btw



你能说明它失败的情况吗?我看不出有任何问题。



Can you show a case where it fails? I can''t see any problem with it.




这是最佳实践之一。的东西。容易混淆document.form

和document.forms

-

Randy

comp .lang.javascript常见问题解答 - http://jibbering.com/faq &新闻组每周

Javascript最佳实践 - http://www.JavascriptToolbox .com / bestpractices /



It''s one of those "Best Practices" things. Easy to confuse document.form
and document.forms

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/


这篇关于如何检查表单是否已更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆