取消选中复选框时是否可以反转数据绑定?

发布于 2024-12-04 02:54:06 字数 286 浏览 0 评论 0原文

我有一个复选框和另一个输入字段,我想将复选框绑定到该输入字段,这很容易。有谁知道当复选框未选中时是否可以反转绑定所做的操作。我的代码如下,任何帮助都会很好,谢谢

<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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清君侧 2024-12-11 02:54:06

每当与复选框交互(选中和取消选中)时,绑定语句都会触发。您只需要确定将如何处理该操作。

要从复选框获取选中的值,请尝试以下操作:

<cfform>
    <cfinput type="checkbox" name="TickBox" value="something">
    <cfinput type="text" name="testing" bind="{TickBox.checked}" value="whatever">
</cfform>

然后您可以将其挂钩到您自己的自定义 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:

<cfform>
    <cfinput type="checkbox" name="TickBox" value="something">
    <cfinput type="text" name="testing" bind="{TickBox.checked}" value="whatever">
</cfform>

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文