我有一个慈善页面,其中包含一个添加额外捐赠的选项。捐赠者必须选中复选框,然后在文本字段中添加金额以便添加。但是,当在文本字段中添加金额时,似乎有些人忽略了复选框,因此不包括额外的捐赠。
这是我的HTML代码 -
<input alt="Additional Donation" id="other_donation_check" onclick="UpdateCost()"
type="checkbox" value="on" />
I would like to make an (additional) <em><strong>tax-deductible</strong></em>
donation of $<input id="other_donation_amount" name="other_donation_amount"
onblur="UpdateCost()" onchange="UpdateCost()" onclick="UpdateCost()"
onfocus="UpdateCost()" size="8" type="text" />
如果在文本字段中添加了任何金额,我可以添加哪些代码来检查复选框?
答案 0 :(得分:0)
尝试:
<script>
function check() {
document.getElementById('other_donation_check').checked = true;
}
</script>
<input alt="Additional Donation" id="other_donation_check" onclick="UpdateCost()" type="checkbox" />
I would like to make an (additional) <em><strong>tax-deductible</strong></em>
donation of $<input id="other_donation_amount" name="other_donation_amount" onkeyUp="check()" size="8" type="text" />