简体   繁体   English

如何在JavaScript中获取更新的值

[英]how to get the updated value in JavaScript

i have a jquery file that have : 我有一个jQuery文件,具有:

document.getElementById('formId:someId').click();
bla = document.getElementById('formId:inputId3').value;            
              if(bla =="koko") {
 alert(" Done ");
 }

in jsf i have the method that change the value of the h:inputText : 在jsf中,我有更改h:inputText的值的方法:

 <h:inputText id="inputId3" value="#{gestionduplanning.testvalue2}" />

 <h:commandButton id="someId" value="Button" action="#{gestionduplanning.exec2()}" style="display:none">
 <f:ajax render="inputId3" execute="@all"/>  
 </h:commandButton>

and in the managed bean i have : 在托管bean中,我有:

   public void exec2() {
    this.testvalue2 = "koko";    
   }

the problem i cant enter the if in Jquery because they still have the first default value before the change. 我无法在Jquery中输入if的问题,因为它们在更改之前仍然具有第一个默认值。

how i can update the update the inputText in the Jquery too be fore the Click on the button ?? 我如何更新更新Jquery中的inputText,也要先单击按钮?

Your code should look like this (its the general idea): 您的代码应如下所示(其基本思路):

document.getElementById('formId:someId').click();

and add the following js function: 并添加以下js函数:

function doTheJs(data) {
    if (data.status === 'success') {
        bla = document.getElementById('formId:inputId3').value;            
        if(bla =="koko") {
            alert(" Done ");
        }
    }
}

and your JSF: 和您的JSF:

<h:commandButton id="someId" value="Button" action="#{gestionduplanning.exec2()}" style="display:none">
    <f:ajax render="inputId3" execute="@all" onevent="doTheJs"/>  
</h:commandButton>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM