<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>Untitled Document</title>
        <script type="text/javascript">
            function update(){
                document.getElementById("form1").submit();
            }
            
            function deleteDb(){
                var actionUrl = document.getElementById("form1").action;
                alert(actionUrl);
                actionUrl = "b.html";
                alert(actionUrl);
                document.getElementById("form1").submit();
            }
        </script>
    </head>
    <body>
        <form action="a.html" name="form1" id="form1">
            <input type="button" value="edit" onclick="javascript:update();"/>
<input type="button" value="delete" onclick="javascript:deleteDb();"/>
        </form>
    </body>
</html>我想当我点击edit按钮时 提交到a.html页面
当我点击delete按钮时 提交到b.html页面 
我的  alert(actionUrl);已经可以改变action的值了为什么页面跳转老是跳转的a.html页面那 有什么解决方法吗 急急急急急

解决方案 »

  1.   

    最直接的解决方法。把2个按钮分开写在2个form里
      

  2.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <title>Untitled Document</title>
      <script type="text/javascript">
      function update(){
      document.getElementById("form1").action="a.html"
      document.getElementById("form1").submit();
      }
        
      function deleteDb(){
       document.getElementById("form1").action="b.html"
      document.getElementById("form1").submit();
      }
      </script>
      </head>
      <body>
      <form action="" name="form1" id="form1">
      <input type="button"  value="edit" onclick="javascript:update();"/>
    <input type="button"  value="delete" onclick="javascript:deleteDb();"/>
      </form>
      </body>
    </html>好使啦 你试试 O(∩_∩)O~ 分开赋值就好了