想通过JavaScript来设置<netui:hidden ..>的值,实现action中辨认何种submit,但是一直没有走通,代码如下:......
<script language="JavaScript">
function set_hidden(value)
{
    document.forms[getNetuiTagName("myform",this)][getNetuiTagName("hidden"),this)].value=value;
    return true;
}
</script>
......<netui:hidden dataSource="actionForm.deal" tagID="hidden" dataInput="actionForm.deal" />
<netui:button value="处理A" onClick="return set_hidden('1');" type="submit" />
<netui:button value="处理B" onClick="return set_hidden('2');" type="submit" />......如何修改?

解决方案 »

  1.   

    <script>
      function contextCommand(command){
        document.getElementById("contextcommand").value=command;
      }
      function makesure(){
        //确认...
      }
    </script>
    <form action=executor.jsp method=post onsubmit="return makesure()"><input type="hidden" name=command value="" id=contextcommand />
    <input type="submit" value="删除记录" id=submit onclick=contextCommand("delcontext") />
    <input type="submit" value="添加记录" id=submit onclick=contextCommand("addcontext") /></form>
    ========================================================================
    executor.jsp:
    ========================================================================
    <%
      String command = request.getParameter("command");
      request.getRequestDispatcher(command+".jsp").forward(request,response);
    %>
    我以前大概是这样做的,可以用的
    上面是随手写出来的,没有调试过,改一下就可以了
      

  2.   

    报什么样的错误?
    document.forms[getNetuiTagName("myform",this)][getNetuiTagName("hidden"),this)].value=value;
    这个语句能通过吗,你把netui:hidden -> netui:text试试,看值赋上了吗?看你的代码,感觉应该没什么问题
      

  3.   

    不用那么麻烦,你用的是struts?如果是就可以用dispatcheraction以及他的子类解决.
    如果不是.你可以考虑这样做. 
    <form name = "form1" action=executor.jsp method=post onsubmit="return makesure()"><input type="hidden" name=command value="" id=contextcommand />
    <input type="submit" value="删除记录" id=submit onclick="form1.action ='executor.jsp?method=delete'"/>
    <input type="submit" value="添加记录" id=submit onclick="form1.action ='executor.jsp?method=add'/></form>
    在action中通过request.getParameter("method")的值来判断执行哪一个函数
      

  4.   

    <input 的类型改为button 然后把提交写在onclick事件里面
      

  5.   

    <input 的类型改为button 然后把提交写在onclick事件里面 如有问题请发邮件[email protected]
      

  6.   

    一个表单多个submit解决方案:
    可以用servlet,你在jsp页面中,多个submit按纽可以设置为一样的name,不同的value。当表单提交给servlet处理时,在servlet中得到submit按纽对应name的value值,然后判断value值,作出相应的处理方法。
    用struts框架的话,可以使用LookupDispatchAction,根据不同的按钮值,用不同的方法处理!