如何检查是否一个复选框状态已改变 [英] How to check if a checkboxes state has changed

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

问题描述

使用.net,我需要生成基于只有那些有有状态改变对我的窗体复选框的响应。所以,我怎么知道,如果复选框已经从previous值在提交前改变。我不能使用onchange事件,因为用户可以在提交之前检查多盒。

Using .Net, I need to generate a response based on only the checkboxes on my form that have had there states changed. So how do I know if the check box has changed from its previous value before submission. I can't use the onchange event because the user may check multiple boxes before submitting.

推荐答案

如果您比较与当前值previous的价值观和他们是不一样的,那么他们已经改变。

If you compare the previous values with the current values and they are not the same, then they have changed.

因此​​节省previous状态成一个对象,该对象的当前状态进行比较。 (录音所作的修改变得更为复杂,如果你想改变什么的两倍你没有提交它的变化)

So save the previous state into an object, and compare that object with the current state. (recording the changes made gets more complicated as if you change something twice you'd not submit it as a change)

这篇关于如何检查是否一个复选框状态已改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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