Skip to main content
Participating Frequently
September 19, 2016
Answered

Auto-advance Numbers in a Form

  • September 19, 2016
  • 1 reply
  • 1295 views

I have a form where I created 12 different text fields.

I would like to enter a number in the the first field and have each of the subsequent fields auto-advance by 1.  So, for example, if the first number is 61, the last number should be 72.

Thanks for your inputs.

This topic has been closed for replies.
Correct answer George_Johnson

Yay!  Almost there!  The fields changed this time.  But one small issue.  It skips what should be the 2nd number in the sequence.


Change:

nStart + i

to:

nStart + i - 1

1 reply

Inspiring
September 20, 2016

What are the field names? You can use a custom validate script for the first field that gets the entered value and sets the other field values, but the script will depend on the names of the 11 subsequent fields.

Participating Frequently
September 20, 2016

I have them numbered "EXHIBIT NO#0" THROUGH "EXHIBIT NO#11". I can re-name them, of course.

Participating Frequently
September 21, 2016

OK, assuming the first field has a numeric format, its custom Validate script could be:

// Custom Validate script for "EXHIBIT#0" field

(function () {

    // Convert this field's value to a number

    var nStart = +event.value;

    // Set the subsequent field values

    // Set to blank if this field is blank

    for (var i = 1; i <= 11; i += 1) {

        getField("EXHIBIT#" + i).value = event.value ? nStart + i : "";

    }

})();


I know how to get to the Validate and enter in a Script, but I've never done it before.

Can I impose on you to break this down a little bit more for someone who hasn't done Scripting before?