我正在制作一个表单,我正在计算使用this作为指南检查是或否的复选框。我可以得到数字,但它没有显示在输入字段中。我看到它更新用firebug查看代码。这是我的减少测试代码。
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("input[value=Yes]").each(function () {
$(this).change(updateCountyes);
});
updateCountyes();
function updateCountyes () {
var countyes = $("input[value=Yes]:checked").size();
$("input#item11_number_1").text(countyes);
$("label#item11").toggle(countyes > 0);
};
$("input[value=No]").each(function () {
$(this).change(updateCountno);
});
updateCountno();
function updateCountno () {
var countno = $("input[value=No]:checked").size();
$("input#item12_number_1").text(countno);
$("label#item12").toggle(countno > 0);
};
});</script>
</head>
<body>
<input type="checkbox" value="Yes" />Yes
<input type="checkbox" value="No" />No
<input type="checkbox" value="Yes" />Yes
<input type="checkbox" value="No" />No
<div id="item11" class="fb-item fb-100-item-column">
<div class="fb-grouplabel">
<label style="display: inline;" id="item11_label_0">Yes</label>
</div>
<div class="fb-input-number">
<input type="number" autocomplete="off" data-hint="" placeholder="" step="1" max="999999999" min="0" id="item11_number_1" name="countyes">
</div>
</div>
<div id="item12" class="fb-item fb-100-item-column">
<div class="fb-grouplabel">
<label style="display: inline;" id="item12_label_0">No</label>
</div>
<div class="fb-input-number">
<input type="number" autocomplete="off" data-hint="" step="1" max="999999999" min="0" id="item12_number_1" name="countno">
</div>
</div>
</body>
</html>