-1

I have a charity page which includes an option to add an additional donation. The donor must check the checkbox then add the amount in a text field for it to be added. But it appears some are overlooking the checkbox when adding the amount in the text field, and so the additional donation is not being included.

Here is the HTML code I have--

<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" />

What can I add to the code that checks the checkbox if any amount is added to the text field?

4

1 回答 1

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" />

小提琴:http: //jsfiddle.net/jzz0sapc/

于 2014-11-28T18:27:16.363 回答