Skip navigation
MadMich
Currently Being Moderated

Conditional text

Mar 20, 2011 8:12 AM

I have several combo boxes with the same 3 items in each.

one of the items = "fail"

If  one or more combo box's = "fail" I want to pass the value to a text box and for it to remain there until none of the combo box's value = "fail".

 

I have tried to fix it by adding a second (hiddden) text box where only the item "fail"  value is added. The only problem is that if the item "fail is removed from  all  the combo boxes the value needs to be removed from the text box. How do I do that , am i on the right track?

 

 

Cheers for any help

 
Replies
  • Currently Being Moderated
    Mar 20, 2011 8:37 AM   in reply to MadMich

    For the custom calculation for the text field:

     

    // array of field names to check
    var aFields = ("CheckBox1", "CheckBox2", "CheckBox3");
    // clear the field's value
    event.value = '';
    // loop through the check boxes and test for 'Failed"
    for(i = 0; i < aFields.length; i++) {
       if(this.getField( aFields[i] ).value == "Failed") {
          // set event value to "{Failed"
          event.value = "Failed";
          } // end match field
       } // end loop of check boxes
     

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 21, 2011 3:58 AM   in reply to MadMich

    You misspelled one of the names of your form fields in the aFields array.

    Remember to pay attention to spaces, and to capitalization.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 21, 2011 5:45 AM   in reply to MadMich

    I see now that there's a different problem. The array is badly defined. It needs to be:

    var aFields = ["CheckBox1", "CheckBox2", "CheckBox3"];

     

    Also, I think there's a logical error in your code. Since you want to check if any of the fields has the "Failed" value you should break the loop once you discover that one of them has that value. Otherwise, you're in effect only checking the last field. So your code should actually be:

     

    // array of field names to check
    var aFields = ["CheckBox1", "CheckBox2", "CheckBox3"];
    // clear the field's value
    event.value = '';
    // loop through the check boxes and test for 'Failed"
    for(i = 0; i < aFields.length; i++) {
    if(this.getField( aFields[i] ).value == "Failed") {
    // set event value to "Failed" and stop
    event.value = "Failed";

    break;
    } // end match field
    } // end loop of check boxes

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 21, 2011 3:39 PM   in reply to MadMich

    Make sure the text field is calculated after the combo-boxes.

    Here's how to edit it:

    - Go to Forms - Edit form in Acrobat

    - Go (again) to Forms - Edit Fields - Set Field Calculation Order

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points