取消选中复选框时是否可以反转数据绑定?
我有一个复选框和另一个输入字段,我想将复选框绑定到该输入字段,这很容易。有谁知道当复选框未选中时是否可以反转绑定所做的操作。我的代码如下,任何帮助都会很好,谢谢
<cfform>
<cfinput type="checkbox" name="TickBox" value="something">
<cfinput type="text" name="testing" bind="{TickBox}" value="whatever">
</cfform>
I have a tick box and another input field that I want to bind the tick box to, this is easy. Does anyone know if you can make it reverse what was done by the binding when the tick box is unticked. The code I have is below, any help on this would be great, thanks
<cfform>
<cfinput type="checkbox" name="TickBox" value="something">
<cfinput type="text" name="testing" bind="{TickBox}" value="whatever">
</cfform>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
每当与复选框交互(选中和取消选中)时,绑定语句都会触发。您只需要确定将如何处理该操作。
要从复选框获取选中的值,请尝试以下操作:
然后您可以将其挂钩到您自己的自定义 javascript(或按照您的评论中的建议),只需您自己的 javascript 单击事件来处理该框的选中/取消选中。
The bind statement will fire any time the checkbox is interacted with (both checking and unchecking). You just have to determine how you're going to handle that action.
To get checked values from a Checkbox, try this:
You can then hook this into your own custom javascript (or as suggested in your comments) just your own javascript click events to handle the checking/unchecking of the box.