By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,693 Members | 1,650 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,693 IT Pros & Developers. It's quick & easy.

immediate if statement

100+
P: 110
I am having some problems getting the immediate if statement (iif) to work in javascript. Is there a particular version of javascript I should be using? I will be operating on an Apache server.
Apr 16 '09 #1
Share this Question
Share on Google+
4 Replies


iam_clint
Expert 100+
P: 1,208
javascript has nothing to do with apache
for an iif in javascript you use it like this
Expand|Select|Wrap|Line Numbers
  1. ((conditions)?"true":"false")
  2.  
Apr 16 '09 #2

100+
P: 110
Okay. Here's my code, according to your instructions. It causes an error saying "object expected"

Expand|Select|Wrap|Line Numbers
  1. var cGVW= iif((cBody=="Tractor")? rtrim(document.getElementById('GVW'+x).value): "");
  2.  
I also tried the syntax I use in other languages but got the same error

Expand|Select|Wrap|Line Numbers
  1. var cGVW= iif(cBody=="Tractor", rtrim(document.getElementById('GVW'+x).value), "");
  2.  
what am I doing wrong?
Apr 17 '09 #3

Dormilich
Expert Mod 5K+
P: 8,639
@andersond
the syntax (as far as I know there is no iif() function).
Expand|Select|Wrap|Line Numbers
  1. var x = condition ? true_statement : false_statement;
see MDC Conditional Operator
Apr 17 '09 #4

iam_clint
Expert 100+
P: 1,208
in my example I never put the letters iif.. it was a correct example
Apr 17 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.