1 Reply Latest reply on Mar 15, 2007 7:06 PM by cyrano27

    Values change after if statement

    cyrano27
      I am putting together a form using 8 Pro UI components. I have a combo box called timeOf_cb. The combo box is loaded with values from 1-12 for the hours of the day. Directly following I have a radio button set called timeSet and the two corresponding radio buttons are labeled AM & PM respectively. in the code below I receive different values from one trace to the next. I've been on this for two days now and I need to get on with this project. It seems like something too simple to get hung up on.

      timeOf = timeOf_cb.selectedIndex;
      pmTrigger = String(optPM_rb.value);

      trace(pmTrigger); // Here my output comes out as "false" if optPM_rb is not chosen

      // Format timeOf

      if (pmTrigger = "true") // This should not trigger if "false" but somehow is triggered anyway.
      {
      trace(pmTrigger); // Here my output comes out as "true" even with no change??
      timeOfLoss = ((timeOf + 12) * 100);
      trace (timeOf);
      }
      else
      {
      timeOf= timeOf;
      }


      * The variables have been declared prior to this line of code as var timeOf, pmTrigger;
        • 1. Values change after if statement
          cyrano27 Level 1
          Sometimes it figures to be something small, one piece of syntax that makes the difference between pull your gray hair out and what a waste of time. The answer to my own post is another "=".

          Cyrano the "if" statement requires a double = before the string literal.

          if (pmTrigger == "true")
          {
          trace(pmTrigger);
          timeOfLoss = ((timeOf + 12) * 100);
          trace (timeOf);
          }
          else
          {
          timeOf= timeOf;
          }


          Now you can dispense with all the extra trace statements and that superfluous Else. What's that about??? LOL

          Coffee anyone?