Reputation: 12935
Here's my HTML:
<input type='checkbox' name='PatientReady1' value='Yes' checked onClick="PatientReady ("PatientReady1","111","PatientReady")">
And my JavaScript:
function PatientReady(element, TriageNo, Field){
debugger;
if (element.checked == 1){
new Ajax.Request (
"PatientReady.asp",
{
method: 'post',
parameters: {
TriageNo: TriageNo,
strReady: "Yes",
strElement: Field
},
asynchronous:false
}
);
}
else{
new Ajax.Request (
"PatientReady.asp",
{
method: 'post',
parameters: {
TriageNo: TriageNo,
strReady: "No",
strElement: Field
},
asynchronous:false
}
);
}
}
For some reason I'm getting a syntax error, when I click on the checkbox... I'm sure I'm missing some tiny stupid thing, perhaps a fresh set of eyes can help?
Upvotes: 0
Views: 1238
Reputation: 5043
Try using this syntax:
<input type='checkbox' name='PatientReady1' value='Yes' checked onClick="PatientReady (this,'111','PatientReady')">
you want to use "this" to reference the actual object, if the funciton were using a 'getElementById' function call, then you would be good, but it's not
Upvotes: 1
Reputation: 41858
As Mark mentioned, if you have double quotes around your string, inside the string should only be single-quotes. It doesn't matter which one you use, but try to be consistent, for readability purposes.
Upvotes: 1
Reputation: 24832
you have double quote both for delimiting and in your onclick event
Upvotes: 0
Reputation: 57658
Use apostrophe instead of quotation mark after onClick:
onClick="PatientReady('PatientReady1','111','PatientReady')"
Also checked should be:
checked="checked"
Upvotes: 1