【问题标题】:How to check if a given variable has the same value as another jQuery如何检查给定变量是否与另一个 jQuery 具有相同的值
【发布时间】:2022-11-03 22:41:29
【问题描述】:

我有 2 个字段,我想检查它们的值是否与 "current_outstanding_balance" 相等,如果是,它会将文本添加到字段 "current_outstanding_balance_check" 。当我将一个 var 添加到循环中时,它正在工作。但是我尝试添加更多类似的东西,但它不起作用。 if(overduer && overdue == fieldNameForResult)

这是我的代码:

function(){
   var fieldNameForResult = thisPointer.entity.getValue('current_outstanding_balance');
   var overduer = thisPointer.entity.getValue('additional_personnel_costs');
   var overdue = thisPointer.entity.getValue('overdue');


   if(overduer && overdue == fieldNameForResult){
       jQ('[id="current_outstanding_balance_check"]').val('True' );


   }else{
       jQ('[id="current_outstanding_balance_check"]').val('False' );


   }

} ```

Now I have no error, but it shows me "False" even though both fields are empty.

【问题讨论】:

    标签: javascript jquery


    【解决方案1】:

    您需要为这两个值添加检查:

    if(overduer == fieldNameForResult && overdue == fieldNameForResult){
    

    【讨论】:

      猜你喜欢
      • 2023-03-29
      • 1970-01-01
      • 2012-11-21
      • 2021-03-22
      • 2019-06-30
      • 1970-01-01
      • 2021-03-28
      • 2011-07-27
      • 1970-01-01
      相关资源
      最近更新 更多