如何检查是否一个复选框状态已改变复选框、状态

2023-09-06 08:33:36 作者:后悔也莫及

使用.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)