0 Replies Latest reply on Oct 4, 2013 9:02 AM by M.Su

    Tallying Fields (Multistate)

    M.Su

      I have a series of faked multistate check box style fields for indicating gender, such as 'M' for male and 'F' for female. The document script is at the bottom.

       

      Is there a way for a field to total the number of males/females?

       

      Also, in a similiar vein, is there a script that can essentially calculated the number of fields that are filled with text? For example, if Fields 'A', 'B', and 'C' are filled, then 'D' would show '3'.

       

      ___________________________________________________________

       

       

      // Array for Button Text and Text Colour

      var bButtonText = [];

      bButtonText.push(["M", color.black]);

      bButtonText.push(["F", color.black]);

      bButtonText.push(["", color.black]);

       

       

      var setNextButtonVal = function (f_name, ap_array) {

       

       

      // Retrieve value of text box associated with multistate button

      var f = getField(f_name);

      var val = f.value;

      // Increment the value by one

      val += 1;

      // Return to beginning if value cannot be located

      if (typeof ap_array[val] === "undefined") {

      val = 0;

      }

      // Update text field value to trigger validation script

      f.value = val;

      }

       

       

      var setNewButtonText = function (b_name, caption_array, val) {

      // Set button text as indicated in array

      var f = getField(b_name);

      f.buttonSetCaption(caption_array[val][0]);

      f.textColor = caption_array[val][1];

      }