Client Script - if Statement with "OR" ||

Laurie Marlowe1
Kilo Sage

Hello,

I cannot figure out how to get this "if" statement to work in a client script.   I know it's a syntax issue, but I cannot figure it out.

This works:

  if ((risk == '') && (changeType != 'Standard'))   {

  g_form.removeOption('state',2); // Sumbitted

  }

This does not work (throws a compiler syntax error:

  if ((risk == '') && (changeType != 'Standard')) || ((risk == '') && (changeType != 'Emergency')) {

  g_form.removeOption('state',2); // Sumbitted

  }

This does not work (Submitted option is removed)

  if (((risk == '') && (changeType != 'Standard')) || ((risk == '') && (changeType != 'Emergency'))) {

  g_form.removeOption('state',2); // Sumbitted

  }

I also tried splitting it into two if statements, and that did not work.

Any ideas?

Thanks,

Laurie

1 ACCEPTED SOLUTION

Laurie Marlowe1
Kilo Sage

WAIT!!!!   Hang on to your hats ladies and gentlemen!!!



The solution is do not use "||" !   Use "&&"!



Thanks,



Laurie


View solution in original post

12 REPLIES 12

Harish KM
Kilo Patron
Kilo Patron

if (risk == '' && changeType != 'Standard' || changeType != 'Emergency' ) {


  g_form.removeOption('state',2); // Sumbitted


  }



let me knw if this doesnt work


Regards
Harish

Harish KM
Kilo Patron
Kilo Patron

// tested


find_real_file.png


Regards
Harish

Hi Harishkumar,



That did not work either.   I also tried using "else if".   This is an onLoad script.



Thank you,



Laurie


Can you post your entire script here?


Regards
Harish