0

这是我的 HTML:

 <input type='checkbox' name='PatientReady1' value='Yes' checked onClick="PatientReady ("PatientReady1","111","PatientReady")">

还有我的 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
                        }

                    );
    }

}

出于某种原因,当我单击复选框时出现语法错误......我确定我错过了一些愚蠢的小东西,也许一双新的眼睛可以提供帮助?

4

4 回答 4

1

在 onClick 之后使用撇号而不是引号:

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

还检查应该是:

checked="checked"
于 2009-09-01T18:53:04.417 回答
1

正如马克所提到的,如果你的字符串周围有双引号,那么字符串内部应该只有单引号。使用哪一个并不重要,但为了便于阅读,请尽量保持一致。

于 2009-09-01T18:54:26.647 回答
1

尝试使用以下语法:

<input type='checkbox' name='PatientReady1' value='Yes' checked onClick="PatientReady (this,'111','PatientReady')">

您想使用“this”来引用实际对象,如果函数使用“getElementById”函数调用,那么您会很好,但事实并非如此

于 2009-09-01T18:56:16.423 回答
0

您在定界和 onclick 事件中都有双引号

于 2009-09-01T18:53:14.887 回答