看看以下这段代码对不对,仔细看,你会看出问题。

  1. <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="tabMainBot"> 
  2.   <tr class="trColor">  
  3.      <td> 
  4.      <input type="text" name="existOrNotStatus" value="${existOrNotStatus}"/> 
  5.       <#if existOrNotStatus=="existData"> 
  6.         <input type="button" name="examinAgree" id="examinAgree" value="同意" class="button" onclick="examinAgree()"/> 
  7.       <#else> 
  8.         <input type="button" name="examinReport" id="examinReport" class="button" value="上报"/> 
  9.       </#if> 
  10.       <input type="button" name="examinDisagree" id="examinDisagree" value="不同意" class="button" onclick="refuseReason()"/> 
  11.       <input name="Button1" type="button" class="button" value="返回" onclick="history.back(-1)"> 
  12.     </td> 
  13.   </tr> 
  14. </table> 
  15.   <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="tabMainBot"> 
  16.   <tbody id="reason" style="display:none;"> 
  17.     <tr class="">  
  18.      <td width="20%"> 
  19.           拒绝理由: 
  20.      </td> 
  21.      <td> 
  22.           <textarea id="returnBack" name="refuseReason" id="refuseReason" class="textarea" rows="5" readonly>${refuseReason?default("")}</textarea> 
  23.     </td> 
  24.   </tr> 
  25.   <tr> 
  26.   <td></td> 
  27.     <td> 
  28.         <input type="button" name="examinConfirm" id="examinConfirm" value="确定" onclick="examinConfirm()"/> 
  29.     </td> 
  30.   </tr> 
  31.   </tbody> 
  32. </table> 

找到了吗?有许多name的值与onclick中的方法名是相同的,开始就这样写的,测试代码的时候一直没有任何反应,也不报错,不管用什么浏览器都是一个样子-没有反应,找了半天也不知道是哪儿错了。叫来同事看了看,他也不知道,这时我说,name的值应该不能与onclick的方法名相同,他说可能是,将同名的方法都改成了另外的名字,测试通过。以前总以为,同一个属性的name名与方法不能相同,现在看来是,只要是name名就不能与方法名相同,不管是不是在同一个属性中。

说明了一个问题,起名字很重要,有的时候一不小心就起成关键字了,再有的时候就出现了上面这种情况,没有任何提示的错误,这就是所谓的经验吧。