看看以下这段代码对不对,仔细看,你会看出问题。
- <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="tabMainBot">
- <tr class="trColor">
- <td>
- <input type="text" name="existOrNotStatus" value="${existOrNotStatus}"/>
- <#if existOrNotStatus=="existData">
- <input type="button" name="examinAgree" id="examinAgree" value="同意" class="button" onclick="examinAgree()"/>
- <#else>
- <input type="button" name="examinReport" id="examinReport" class="button" value="上报"/>
- </#if>
- <input type="button" name="examinDisagree" id="examinDisagree" value="不同意" class="button" onclick="refuseReason()"/>
- <input name="Button1" type="button" class="button" value="返回" onclick="history.back(-1)">
- </td>
- </tr>
- </table>
- <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="tabMainBot">
- <tbody id="reason" style="display:none;">
- <tr class="">
- <td width="20%">
- 拒绝理由:
- </td>
- <td>
- <textarea id="returnBack" name="refuseReason" id="refuseReason" class="textarea" rows="5" readonly>${refuseReason?default("")}</textarea>
- </td>
- </tr>
- <tr>
- <td></td>
- <td>
- <input type="button" name="examinConfirm" id="examinConfirm" value="确定" onclick="examinConfirm()"/>
- </td>
- </tr>
- </tbody>
- </table>
找到了吗?有许多name的值与onclick中的方法名是相同的,开始就这样写的,测试代码的时候一直没有任何反应,也不报错,不管用什么浏览器都是一个样子-没有反应,找了半天也不知道是哪儿错了。叫来同事看了看,他也不知道,这时我说,name的值应该不能与onclick的方法名相同,他说可能是,将同名的方法都改成了另外的名字,测试通过。以前总以为,同一个属性的name名与方法不能相同,现在看来是,只要是name名就不能与方法名相同,不管是不是在同一个属性中。
说明了一个问题,起名字很重要,有的时候一不小心就起成关键字了,再有的时候就出现了上面这种情况,没有任何提示的错误,这就是所谓的经验吧。