如果通过javascript检查另一个复选框,如何自动取消选中复选框? [英] How to automatically uncheck a checkbox if another checkbox is checked through javascript?

查看:78
本文介绍了如果通过javascript检查另一个复选框,如何自动取消选中复选框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个复选框Birthdate,仅显示mm / dd。在它下面还有另一个名为ShowYear的复选框,它显示年份,只有选中Bithdate复选框时才会显示此复选框。

I have a checkbox Birthdate which shows the mm/dd only.And below it there is another checkbox called ShowYear which shows the year and this checkbox is only visible if the Bithdate checkbox is checked.

现在,如果通过javascript取消选中Birthdate复选框
,我想自动取消选中ShowYear复选框。

Now I want to uncheck the ShowYear checkbox automatically if the Birthdate checkbox is unchecked through javascript.

推荐答案

<input id="cbxBirthDate" type="checkbox" onClick="javascript:uncheckShowYear(this);" />
<input id="cbxShowYear" type="checkbox" />


<script language="javascript" type="text/javascript">
function uncheckShowYear(obj)
        {
            if (obj.checked == false)
            {
                document.getElementById("cbxShowYear").checked = false;
            }
        }
</script>

这篇关于如果通过javascript检查另一个复选框,如何自动取消选中复选框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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