<script type="text/javascript"> 
function auth(obj) {
 if (confirm("Do you really want to authenticate this employee?")) {
  obj.setAttribute('disabled', 'true');
  document.getElementById('method').value='auth';
  obj.form.submit();
 }
 return false;
}function reject(obj) {
 if (confirm("Do you really want to reject this employee?")) {
  obj.setAttribute('disabled', 'true');
  document.getElementById('method').value='reject';
  obj.form.submit();
 }
 return false;
}
</script>
<form id="Employee_auth_NONGS" name="tempEmployeeForm" onsubmit="return true;" action="/employee/Employee_auth_NONGS.do" method="post">
    <input type="hidden" name="method" value="" id="method"/>
  <input type="submit" id="Employee_auth_NONGS_0" value="Authenticate" onclick="auth(this)"/>  <input type="submit" id="Employee_auth_NONGS_1" value="Reject" onclick="reject(this)"/></form>
为什么在方法里写的return false,弹出confirm对话框 点取消button ,还是会刷新页面呢

解决方案 »

  1.   

    <form id="Employee_auth_NONGS" name="tempEmployeeForm" onsubmit="return true;" action="/employee/Employee_auth_NONGS.do" method="post"> 
        <input type="hidden" name="method" value="" id="method"/> 
      <input type="button" id="Employee_auth_NONGS_0" value="Authenticate" onclick="auth(this)"/>   <input type="button" id="Employee_auth_NONGS_1" value="Reject" onclick="reject(this)"/> </form> 
      

  2.   

      <input type="submit" id="Employee_auth_NONGS_0" value="Authenticate" onclick="return auth(this)"/>   <input type="submit" id="Employee_auth_NONGS_1" value="Reject" onclick="return reject(this)"/> 
      

  3.   

    只写关键代码
    return reject(this)return 怎么能少呢?
      

  4.   


       <script type="text/javascript"> 
    function auth(obj) { 
    if (confirm("Do you really want to authenticate this employee?")) { 
      obj.setAttribute('disabled', 'true'); 
      document.getElementById('method').value='auth'; 
      obj.form.onsubmit=true;
      obj.form.submit(); 
    }} function reject(obj) { 
    if (confirm("Do you really want to reject this employee?")) { 
      obj.setAttribute('disabled', 'true'); 
      document.getElementById('method').value='reject'; 
      obj.form.onsubmit=true;
      obj.form.submit(); 
    }} 
    </script> 
    <form id="Employee_auth_NONGS" name="tempEmployeeForm" onsubmit="return true;" action="/employee/Employee_auth_NONGS.do" method="post"> 
        <input type="hidden" name="method" value="" id="method"/> 
      <input type="button" id="Employee_auth_NONGS_0" value="Authenticate" onclick="auth(this)"/>   <input type="button" id="Employee_auth_NONGS_1" value="Reject" onclick="reject(this)"/> </form> 
      

  5.   

     <script type="text/javascript"> 
    function auth(obj) { 
    if (confirm("Do you really want to authenticate this employee?")) { 
      obj.setAttribute('disabled', 'true'); 
      document.getElementById('method').value='auth'; 
      obj.form.submit(); 
    }} function reject(obj) { 
    if (confirm("Do you really want to reject this employee?")) { 
      obj.setAttribute('disabled', 'true'); 
      document.getElementById('method').value='reject'; 
      obj.form.submit(); 
    }} 
    </script> 
    <form id="Employee_auth_NONGS" name="tempEmployeeForm" onsubmit="return true;" action="/employee/Employee_auth_NONGS.do" method="post"> 
        <input type="hidden" name="method" value="" id="method"/> 
      <input type="button" id="Employee_auth_NONGS_0" value="Authenticate" onclick="auth(this)"/>   <input type="button" id="Employee_auth_NONGS_1" value="Reject" onclick="reject(this)"/> </form> 不好意思上面的有问题!
      

  6.   

    加return 。另外submit与button也有点区别的。
      

  7.   


    顶个~~submit是根据返回值判断执行的