<script type="text/javascript" language="javascript">
function fangfa(){document.form[0].action="user2.do";
document.form[0].submit();
}</script>
<body>
<form action="user1.do">
<input  type="text" name="user.name"/>
<input  type="text" name="user.password"/>
<input  type="submit" value="User1" />
<input  type="submit" value="User2" onclick="fangfa();"/>
</form>
反正就是想js和struts1结合用,有两个按钮,第一个默认点击之后就跳到表单action指定的地方,第二个按钮就要执行onclick事件,让它跳到另一个action去,但是无法实现,我怀疑我的函数写错了,还是思路错了,还是本来就不能这样的,请高手指教。。就是想办法两个按钮跳不同的action

解决方案 »

  1.   

    <script type="text/javascript" language="javascript">
    function fangfa(){document.forms[0].action="user2.do";
    document.forms[0].submit();
    }</script>
    <body>
    <form action="user1.do">
    <input  type="text" name="user.name"/>
    <input  type="text" name="user.password"/>
    <input  type="submit" value="User1" />
    <input  type="button" value="User2" onclick="fangfa();"/>
    </form>
      

  2.   

    <input  type="submit" value="User2" onclick="fangfa();"/>
    改成
    <input  type="button" value="User2" onclick="fangfa();"/>