In the following code I just want to disable the textbox if “other Amount is selected”, radio element 7.
I have been working at this too long cause I can’t see the problem. Can someone point out what I am doing incorrectly
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title> Donation page Goes Here </title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<script type="text/javascript" src="../js/jquery.js"></script>
<body>
<p>
Contributions are tax deductable for residents of the United States and Jamaica.
</p>
<p>
Yes, I want to become a contributor. Please accept my donation as indicated below.
(Contributions in $US only; please check one):
</p>
<div id="donationForm">
<form id="formDonate" name="formDonate" method ='request' onsubmit='return isNumeric();' action='content/creditCardAuthorize.php'>
<fieldset id="fieldDonate">
<legend>Donation Form</legend> <br />
<p><input type='radio' id="donation" name='donation' value='10' /> $10</p>
<p><input type='radio' id="donation" name='donation' value='20' /> $20 </p>
<p><input type='radio' id="donation" name='donation' value='30' /> $30 </p>
<p><input type='radio' id="donation" name='donation' value='40' /> $40 </p>
<p><input type='radio' id="donation" name='donation' value='50' /> $50 </p>
<p><input type='radio' id="donation" name='donation' value='75' /> $75 </p>
<p><input type='radio' id="donation" name='donation' value='100' /> $100</p>
<p><input type='radio' id="donation" name='donation' value='' /> Other Amount </p>
<br />
<p>
<label for='amount'>Amount $</label> <input type='text' name='amount' id='amount' />
<span id="errmsg"></span>
</p>
<p class='submit'><input type='submit' id="donateButton" value='Continue' /></p>
<br />
</fieldset>
</form>
</div>
<script type="text/javascript">
$("input:radio[@name='donation']").change(function(){
/* $("#amount, :text").val( $("input[@name='donation']")); */
$("#amount, :text").val( $('input[name=donation]:checked').val());
if(document.formDonate.donation[7].selected){
document.formDonate.amount.disabled = false;
document.formDonate.amount.focus();
}
else{
document.formDonate.amount.disabled = true;
}
});
$("#amount").keypress(function (e){
//if the letter is not digit then display error and don't type anything
if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57)){
//display error message
$("#errmsg").html("Digits Only").show().fadeOut("slow");
return false;
}
});
</script>
</body>
</html>