- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2017 10:56 AM
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
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2017 11:50 AM
WAIT!!!! Hang on to your hats ladies and gentlemen!!!
The solution is do not use "||" ! Use "&&"!
Thanks,
Laurie

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2017 11:24 AM
I dont think onload will work here since you have 2 values running on type field comparng Standard and emergency. Where as onload will work only ones when the form opens for the first time.
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2017 11:41 AM
Do you have any ideas how to work around this?
Thank you,
Laurie

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2017 11:25 AM
FYI - Order of precedence is always worth noting when stringing operators together. When in doubt, I always put () around what I want to work first.
Operator precedence - JavaScript | MDN
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2017 11:46 AM
Hi Chuck,
I tried switching the order of precedence (putting the OR condition before the && condition) and that didn't work. So then, I removed the && condition, just to see if the OR would work by itself, and it did not. I'm thinking harishkumar may be on to something about 2 values running on the type field for an onLoad script???
Thanks,
Laurie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2017 11:50 AM
WAIT!!!! Hang on to your hats ladies and gentlemen!!!
The solution is do not use "||" ! Use "&&"!
Thanks,
Laurie