Maison >développement back-end >tutoriel php >不太熟悉PHP编程,为什么总报缺少‘)’错误?
劳大家帮我看看,为什么总是报if(form1.2_ytbyx.value==""){错误,说缺少‘(’?万分感谢!
<input type="button" name="Submit" value="提交" onClick="process() "></td> <script> function process(){ //alert("开始检验!"); if(form1.2_ytbyx.value==""){ alert("您所输入的分值不能为空!"); form1.2_ytbyx.select(); }else if(checkscore20(form1.2_ytbyx.value)!=true){ alert("您输入的分值不正确!当前分值不应超过20分!"); form1.2_ytbyx.select(); return(false); }else{ var ytbyx = parseInt(document.getElementById("2_ytbyx").value); //alert("您输入的数值通过检验!请确认!"); }
完全是js的代码,没看到php的
因为报错只有这一段所以摘录了一下,主要程序如下:
<body onkeydown="keydown()"><form name="form1" method="post" > <table width="750" height="228" border="1" cellpadding="1" cellspacing="1" bordercolor="#FFFFFF" bgcolor="#666666"> <tr> <td height="20" colspan="11" bgcolor="#EEEEEE" class="STYLE1"> 论证项目</td> </tr> <tr> <td align="center" width="17" bgcolor="#EEEEEE" class="STYLE1">序<br> 号</td> <td align="center" width="40" bgcolor="#EEEEEE" class="STYLE1">项目<br> 名称</td> <td width="255" align="center" bgcolor="#EEEEEE" class="STYLE1">用途及总要求</td> <td width="50" align="center" bgcolor="#EEEEEE" class="STYLE1">用途和<br> 必要性<br> (20分)</td> <td width="60" align="center" bgcolor="#EEEEEE" class="STYLE1">研究目标<br> 和内容<br> (15分)</td> <td width="50" align="center" bgcolor="#EEEEEE" class="STYLE1">主要战<br> 技指标<br> (15分)</td> <td width="60" align="center" bgcolor="#EEEEEE" class="STYLE1">研究方法<br> 和技术途径<br> (15分)</td> <td width="55" align="center" bgcolor="#EEEEEE" class="STYLE1">推广应用<br> 前景和效<br> 益分析<br> (15分)</td> <td width="55" align="center" bgcolor="#EEEEEE" class="STYLE1">进度和<br> 经费安排<br> (5分)</td> <td width="55" align="center" bgcolor="#EEEEEE" class="STYLE1">综合评分<br> (15)分</td> </tr> <?php $xm_lbes1="论证项目"; $query1=mssql_query("select * from tb_xm where xm_lb='$xm_lbes1' and xm_pcid='$online_xmpc'"); $x=1; while($myrow1=mssql_fetch_array($query1)){?> <tr> <td height="20" bgcolor="#FFFFFF" class="STYLE1"><?php echo $x."."?></td> <td align="left" height="20" width="40" bgcolor="#FFFFFF" class="STYLE1"><?php echo $myrow1["xm_name"]?></td> <td height="20" bgcolor="#FFFFFF" class="STYLE1"><?php echo $myrow1["xm_ytyq"]?></td> <td height="20" align="center" bgcolor="#FFFFFF" class="STYLE1"><input type="text" name="<?php echo $myrow1["xm_id"]."_ytbyx";?>" style="text-shadow" id="<?php echo $myrow1["xm_id"]."_ytbyx";?>" align="middle" width="50" size="5"> <!-- 插入size= 你要的文字长度--></td> <td height="20" align="center" bgcolor="#FFFFFF" class="STYLE1"><input name="<?php echo $myrow1["xm_id"]."_mbnr";?>" style="text-shadow" id="<?php echo $myrow1["xm_id"]."_mbnr";?>" align="middle" width="60" size="6"> </td> <td height="20" align="center" bgcolor="#FFFFFF" class="STYLE1"><input name="<?php echo $myrow1["xm_id"]."_zjzb";?>" style="text-shadow" id="<?php echo $myrow1["xm_id"]."_zjzb";?>" width="50" size="5"> </td> <td height="20" align="center" bgcolor="#FFFFFF" class="STYLE1"><input name="<?php echo $myrow1["xm_id"]."_ffjs";?>" style="text-shadow" id="<?php echo $myrow1["xm_id"]."_ffjs";?>" align="middle" width="60" size="7"> </td> <td height="20" align="center" bgcolor="#FFFFFF" class="STYLE1"><input name="<?php echo $myrow1["xm_id"]."_xyqj";?>" style="text-shadow" id="<?php echo $myrow1["xm_ide"]."_xyqj";?>" align="middle" width="55" size="6"> </td> <td height="20" align="center" bgcolor="#FFFFFF" class="STYLE1"><input name="<?php echo $myrow1["xm_id"]."_jdjf";?>" style="text-shadow" id="<?php echo $myrow1["xm_id"]."_jdjf";?>" align="middle" width="55" size="6"> </td> <td height="20" align="center" bgcolor="#FFFFFF" class="STYLE1"><input name="<?php echo $myrow1["xm_id"]."_zhpf";?>" style="text-shadow" id="<?php echo $myrow1["xm_id"]."_zhpf";?>" align="middle" width="55" size="6"></td> </tr> <?php $x++;} ?> <tr> <td height="20" colspan="11" bgcolor="#EEEEEE" class="STYLE1"> 技术研究项目</td> </tr> <tr> <td height="20" colspan="11" bgcolor="#EEEEEE" class="STYLE1"> 改进研制项目</td> </tr> <?php $query2=mssql_query("select * from tb_kt where kt_lb='$kt_lbes' and kt_lx='2' and kt_small_lb='$kt_small_lb'");$z=1;$fen2=0; while($myrow2=mssql_fetch_array($query2)){ ?><tr> <td height="20" colspan="11" bgcolor="#FFFFFF" class="STYLE1"> </td> </tr> <?php $z++;} ?> <tr> <td height="20" colspan="11" bgcolor="#EEEEEE" class="STYLE1"> 使用研究项目</td> </tr> <tr> <td height="20" colspan="11" bgcolor="#FFFFFF" class="STYLE1"> </td> </tr> <tr> <td height="20" colspan="11" bgcolor="#EEEEEE" class="STYLE1"> 试验验证项目</td> </tr> <tr> <td height="20" colspan="11" bgcolor="#FFFFFF" class="STYLE1"> </td> </tr> <tr> <td colspan="10" align="center" bgcolor="#FFFFFF" class="STYLE1"> <input type="hidden" value="<?php echo $_POST[kt_lbes]?>" name="kt_lbes"> <input type="hidden" value="<?php echo $_POST[kt_small_lb]?>" name="kt_small_lb"> <input type="button" name="Submit" value="提交" onClick="process() "></td> <script> function process(){ <?php $query0=mssql_query("select * from tb_xm where xm_pcid='$online_xmpc'"); $y=1; while($myrow0=mssql_fetch_array($query0)){ ?> //alert("开始检验!"); if(form1.<?php echo $myrow0["xm_id"]."_ytbyx";?>.value==""){ alert("您所输入的分值不能为空!"); form1.<?php echo $myrow0["xm_id"]."_ytbyx";?>.select(); }else if(checkscore20(form1.<?php echo $myrow0["xm_id"]."_ytbyx";?>.value)!=true){ alert("您输入的分值不正确!当前分值不应超过20分!"); form1.<?php echo $myrow0["xm_id"]."_ytbyx";?>.select(); return(false); }else{ var ytbyx = parseInt(document.getElementById("<?php echo $myrow0["xm_id"]."_ytbyx";?>").value); //alert("您输入的数值通过检验!请确认!"); } if(form1.<?php echo $myrow0["xm_id"]."_mbnr";?>.value==""){ alert("您所输入的分值不能为空!"); form1.<?php echo $myrow0["xm_id"]."_mbnr";?>.select(); }else if(checkscore15(form1.<?php echo $myrow0["xm_id"]."_mbnr";?>.value)!=true){ alert("您输入的分值不正确!当前分值不应超过15分!"); form1.<?php echo $myrow0["xm_id"]."_mbnr";?>.select(); return(false); }else{ var mbnr = parseInt(document.getElementById("<?php echo $myrow0["xm_id"]."_mbnr";?>").value); } if(form1.<?php echo $myrow0["xm_id"]."_zjzb";?>.value==""){ alert("您所输入的分值不能为空!"); form1.<?php echo $myrow0["xm_id"]."_zjzb";?>.select(); }else if(checkscore15(form1.<?php echo $myrow0["xm_id"]."_zjzb";?>.value)!=true){ alert("您输入的分值不正确!当前分值不应超过15分!"); form1.<?php echo $myrow0["xm_id"]."_zjzb";?>.select(); return(false); }else{ var zjzb = parseInt(document.getElementById("<?php echo $myrow0["xm_id"]."_zjzb";?>").value); } if(form1.<?php echo $myrow0["xm_id"]."_ffjs";?>.value==""){ alert("您所输入的分值不能为空!"); form1.<?php echo $myrow0["xm_id"]."_ffjs";?>.select(); }else if(checkscore15(form1.<?php echo $myrow0["xm_id"]."_ffjs";?>.value)!=true){ alert("您输入的分值不正确!当前分值不应超过15分!"); form1.<?php echo $myrow0["xm_id"]."_ffjs";?>.select(); return(false); }else{ var ffjs = parseInt(document.getElementById("<?php echo $myrow0["xm_id"]."_ffjs";?>").value); } if(form1.<?php echo $myrow0["xm_id"]."_xyqj";?>.value==""){ alert("您所输入的分值不能为空!"); form1.<?php echo $myrow0["xm_id"]."_xyqj";?>.select(); }else if(checkscore15(form1.<?php echo $myrow0["xm_id"]."_xyqj";?>.value)!=true){ alert("您输入的分值不正确!当前分值不应超过15分!"); form1.<?php echo $myrow0["xm_id"]."_xyqj";?>.select(); return(false); }else{ var xyqj = parseInt(document.getElementById("<?php echo $myrow0["xm_id"]."_xyqj";?>").value); } if(form1.<?php echo $myrow0["xm_id"]."_jdjf";?>.value==""){ alert("您所输入的分值不能为空!"); form1.<?php echo $myrow0["xm_id"]."_jdjf";?>.select(); }else if(checkscore5(form1.<?php echo $myrow0["xm_id"]."_jdjf";?>.value)!=true){ alert("您输入的分值不正确!当前分值不应超过5分!"); form1.<?php echo $myrow0["xm_id"]."_jdjf";?>.select(); return(false); }else{ var jdjf = parseInt(document.getElementById("<?php echo $myrow0["xm_id"]."_jdjf";?>").value); } if(form1.<?php echo $myrow0["xm_id"]."_zhpf";?>.value==""){ alert("您所输入的分值不能为空!"); form1.<?php echo $myrow0["xm_id"]."_zhpf";?>.select(); }else if(checkscore15(form1.<?php echo $myrow0["xm_id"]."_zhpf";?>.value)!=true){ alert("您输入的分值不正确!当前分值不应超过15分!"); form1.<?php echo $myrow0["xm_id"]."_zhpf";?>.select(); return(false); }else{ var zhpf = parseInt(document.getElementById("<?php echo $myrow0["xm_id"]."_zhpf";?>").value); } var sum = ytbyx+mbnr+zjzb+ffjs+xyqj+jdjf+zhpf; function datawrite<?php echo $y?>(){ //此处使用了嵌套函数形式,使其可以判断服务器状态 var xmlHttp=createXmlHttpRequestObject(); if(xmlHttp.readyState==4 || xmlHttp.readyState==0){ xmlHttp.open("GET","kspf_conn1.php?online_xm="+"<?php echo $myrow0["xm_name"]?>"+"&online_user="+"<?php echo $online_user?>"+"&online_ytbyx="+ytbyx+"&online_mbnr="+mbnr+"&online_zjzb="+zjzb+"&online_ffjs="+ffjs+"&online_xyqj="+xyqj+"&online_jdjf="+jdjf+"&online_zhpf="+zhpf+"&online_sum="+sum,true); xmlHttp.send(null); }else{ alert("datawrite()中xmlHttp对象忙!"); setTimeout('datawrite<?php echo $y?>()',10); } } var xmlHttp=createXmlHttpRequestObject(); datawrite<?php echo $y?>(); <?php $y++; } ?> //此处对项目批次与评委的相关性进行打分 } </script> </tr> </table></form><?php if($Submit=="提交"){$data=date("Y-m-d H:i:s");$grade="update tb_user set online_grade='$zf',online_subject='$_POST[kt_lbes]',online_pt='1',online_date='$data' where online_number='$_SESSION[online_number]'";$grade_result=mssql_query($grade);}?></body></html>
<script> <br /> var form1 = getElementsByTagName('form'); </script>
改下input的name命名试试,不要数字开头
听楼上的建议。所有的input改为名字_数字的形式。
如1_mnbr => mbnr_1
否则会报js warning 的。
不明白的是,你的怎么会报php错误。
不是听楼上的建议,而是遵从变量命名规则
不守规矩,当然是后果自负
变量命名规则:以字母或下划线开头,后跟若干个字母、数字、下划线
的确是命名规则出了问题,看来还是踏实系统地学习啊!谢谢各位了!