views:

308

answers:

4

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?

+1  A: 

Use apostrophe instead of quotation mark after onClick:

onClick="PatientReady('PatientReady1','111','PatientReady')"

Also checked should be:

checked="checked"
Zed
Just `checked` is fine and legal in HTML.
John Millikin
A: 

you have double quote both for delimiting and in your onclick event

Gregoire
+1  A: 

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.

James Black
+1  A: 

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

Jay