Hi bud
Wile boolean values like true and false don’t need to be wrapped in quotes string values like “normal” and “#ffffff” do, one thing to note here is that the hex value for black is “#000000”
If you want your variable “style” to reference your p element's style you will need to change it to:
document.getElementById(style).style
The other thing is that in javascript because the “-” is the minus sign javascript thinks that you are trying to subtract “style.font” from “weight” which as you might imagine throws up an error. So it needs to be changed to “style.fontWeight”.
Here is a working version of your code:
<p id="p1" style="color: #FF0000; font-weight: bold;">I have read and agree to the terms and conditions
<input type="checkbox" id="termsChkbx" onclick="hasReadTerms( this.id, 'sub1', 'p1')" /></p>
<p><input type="submit" name="submit" value="Order now!" id="sub1" disabled="disabled"/></p>
<script type="text/javascript">
function hasReadTerms( checkBoxID, buttonID, style) {
// only enable the submit button if the accept terms box is checked
var chkbx = document.getElementById( checkBoxID );
var submitBtn = document.getElementById( buttonID );
var style = document.getElementById( style ).style;
if ( chkbx.checked ) {
submitBtn.disabled = false;
style.color = "#000000";
style.fontWeight= "normal";
}
else {
submitBtn.disabled = true;
style.color = "#FF0000";
style.fontWeight= "bold";
}
}
</script>