如何让action先执行 再执行onClickfunction printOn(){
var buttonYwlsh = document.getElementById('print');
var ywlsh = document.getElementById('ywlsh').value;
alert(ywlsh);
if(ywlsh!=null||ywlsh!="")
button.disabled = false;
}<tr align="center">
<td class="bodyFont" align="right"></td>
<td>
<t:commandButton id="save" value="过户确认" action="#{guohuBean.save}" 
onclick="printOn()"
styleClass="button" style="top:10px  position: relative; width: 99px" />
</td>
         <td align="center" style="width: 123px;">
<input type="button" id="print" name="print" style="width: 120"
onclick="printGhd()" value="打印过户单" disabled="disabled" class="button">
</td>
</tr>

解决方案 »

  1.   

    function printOn(){
    var buttonYwlsh = document.getElementById('print');
    var ywlsh = document.getElementById('ywlsh').value;
    alert(ywlsh);
    if(ywlsh!=null||ywlsh!="")
    button.disabled = false;
    }
    ]<tr align="center">
    <td class="bodyFont" align="right"></td>
    <td>
    <t:commandButton id="save" value="过户确认" action="#{guohuBean.save}"  
    onclick="printOn()"
    styleClass="button" style="top:10px position: relative; width: 99px" />
    </td>
      <td align="center" style="width: 123px;">
    <input type="button" id="print" name="print" style="width: 120"
    onclick="printGhd()" value="打印过户单" disabled="disabled" class="button">
    </td>
    </tr>
      

  2.   

    可以通过Ajax提交Action,然后在Ajax的success函数中,写onclick事件中的js代码
      

  3.   

    先执行action后 ywlsh 才会有值  按钮才让启用  
    简单的说,就是 先执行action  执行成功后  ywlsh就会有值  然后我判断这个有值  打印按钮就可以启用  
    看到的帮下忙呀 急 
      

  4.   

    最简单的办法是不是
    h:commandButton
    换为
    a:commandButtononclick
    换为
    oncomplete? 我想问一下  这个a  是
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t" %> 
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
    我没有这个a 标签    这个怎么写  有的 发出来一下 
      

  5.   

    还是建议楼主用jQuery的ajax、get请求