7 Replies Latest reply on Feb 11, 2014 12:29 PM by meljar

    Problems auto-filling a text box

    meljar

      Hi,

       

      I am trying to populate a text field with either "Yes" or "No" based on the value placed in another text field. If the value in [textfield 1] is greater than 0, I want a "No" to appear in [text field 2] and if the value of [textfield 1] = 0, I want a "Yes" to appear in [text field 2]. If [textfield 1] is blank, I want [textfield 2] to be blank. I have put the following code into the Custom Calculation area of [textfield 2]:

       

      var a = this.getField("textfield 1").value;

       

      if(a=="") event.value = "";

       

      else if(a>0) event.value = "No";

       

      else if(a==0) event.value = "Yes";

       

      Currently if the value from [textfield 1] is greater than 0 a "No" will appear, but the field remains blank if the value of [text field 1] = 0. I'm not sure why this is. This code has worked for me before when the value conditions are different. Is it something to do with the 0?

       

      I also want some other fields to be visible when [textfield 2] is populated with a "No" in the box and hidden when [text field 2] is populated with a "Yes". This is the code I used in the custom  validation script:

       

      if (event.value =="Yes") {

       

           this.getField("textfield 3").display = display.hidden;

       

           this.getField("checkbox1").display = display.hidden;

       

      } else if(event.value =="No") {

       

           this.getField("textfield 3").display = display.hidden;

        

           this.getField("checkbox1").display = display.hidden;

      }

       

      Again this code has worked for me for other fields. I'm thinking it doesn't work now because I don't have the Calculation Script working yet?

       

      Any help would be greatly appreciated. Thanks!