Home > other >  How to check if a given variable has the same value as another jQuery
How to check if a given variable has the same value as another jQuery

Time:11-04

I have 2 fields that I would like to check if their values are equal with "current_outstanding_balance" If so, it adds text to the field "current_outstanding_balance_check" . It's working when i add one var to loop. But i tried add more like, but it's not working. if(overduer && overdue == fieldNameForResult)

This is my code:

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.

CodePudding user response:

You need to add the check for both values:

if(parseFloat(overduer)   parseFloat(overdue) == parseFloat(fieldNameForResult)){
  • Related