immediate if statement

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • andersond
    New Member
    • Feb 2007
    • 110

    immediate if statement

    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.
  • iam_clint
    Recognized Expert Top Contributor
    • Jul 2006
    • 1207

    #2
    javascript has nothing to do with apache
    for an iif in javascript you use it like this
    Code:
    ((conditions)?"true":"false")

    Comment

    • andersond
      New Member
      • Feb 2007
      • 110

      #3
      Okay. Here's my code, according to your instructions. It causes an error saying "object expected"

      Code:
      var cGVW= iif((cBody=="Tractor")? rtrim(document.getElementById('GVW'+x).value): "");
      I also tried the syntax I use in other languages but got the same error

      Code:
      var cGVW= iif(cBody=="Tractor", rtrim(document.getElementById('GVW'+x).value), "");
      what am I doing wrong?

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        Originally posted by andersond
        what am I doing wrong?
        the syntax (as far as I know there is no iif() function).
        Code:
        var x = condition ? true_statement : false_statement;
        see MDC – Conditional Operator

        Comment

        • iam_clint
          Recognized Expert Top Contributor
          • Jul 2006
          • 1207

          #5
          in my example I never put the letters iif.. it was a correct example

          Comment

          Working...