2 Replies Latest reply on Nov 27, 2011 12:41 PM by stealthrs

    If Then Statement to not be CaSe-Sensitive?


      Hey guys.  The two pages I have to fill out for work contain the same data, but their question numbers are different and I have to convert the question numbers. I have two textfields:  HQ_1# and HQ_1#DI and   I've written a giant if then statement to act as the question converter to re-letter the inputs to what is appropriate on this other page (there's like 20 entry items).... It looks something like this


      // "Sloppy Code"

      var li1 = this.getField("HQ_1#");

      var di1 = this.getField("HQ_1#DI");


      if (li1.value=="1C" || li1.value=="1c")


          di1.value = "1A)";


      else if (li1.value=="1D" || li1.value=="1d")


          di1.value = "1B)";




          di1.value = "";




      So as I put 1c or 1C in the form above, it reprints to A below..... GREAT!! But, this is not optimal coding... I would like to learn how to code efficiently, so basically I would like to trim it to where it's something like if (li1.value=="1C" || li1.value=="1c") and work regardless of 1c or 1C being entered... I know that there's a way to get the if then to not be case sensitive, but I can't figure it out... I added this code in the custom calculation box in HQ_1# to see if this would work, but it doesn't:


      if (event.value!=null) event.value = event.value.toUpperCase();


      After adding this code, HQ_1# will visually show as uppercase 1C if '1c' is entered, but I guess it still stores as '1c'.... Which my problem...  The "trimmed" code of if (li1.value=="1C") doesn't display 1A because I typed in '1c'.... Although '1C' shows up.  So basically I've taken this out for the meantime and I've gone with my Sloppy Code.


      P.S.  This is the first thing I've actually done by myself, so I'm happy with my work thus far.