Skip to main content
kareng26030666
Participating Frequently
April 28, 2017
Answered

Incrimental buttons for spawned pages.

  • April 28, 2017
  • 2 replies
  • 660 views

I have a form that has fields that will be used to tally devices. I created the button and the form fileds. It works perfectly but not on spawned pages.

This is the script im currently using.

var prefix = ".";

var nameParts = event.target.name.split(".");

if (nameParts.length > 2) {

      prefix = nameParts[0] + "." + nameParts[1] + ".";}

var oFld = +this.getField("QWR");

if(isNaN(oFld.value))

oFld.value = 0;

else

oFld.value += 1;

Any help will be greatly appreciated.

This topic has been closed for replies.
Correct answer gkaiseril

The following code works for me:

var prefix = ""; // for template assume null prefix;

var nameParts = event.target.name.split("."); // split spawned renamed field name into an array;

if (nameParts.length > 2) {

      prefix = nameParts[0] + "." + nameParts[1] + "."; // first 2 elements of the array will be the "P#" and the template name;

}

var oFld = this.getField(prefix + "QWR"); // access field name with spawned prefix values;

if(isNaN(oFld.value))

oFld.value = 0;

else

oFld.value += 1;

2 replies

Inspiring
April 29, 2017

Have you looked at the spawned pages in the field edit mode?

If not you should.

Try;

var prefix = ""; // for template assume null prefix;

var nameParts = event.target.name.split("."); // split spawned renamed field name into an array;

if (nameParts.length > 2) {

      prefix = nameParts[0] + "." + nameParts[1] + "."; // first 2 elements of the array will be the "P#" and the template name;

}

var oFld = +this.getField(prefix + "QWR"); // access field name with spawned prefix values;

if(isNaN(oFld.value))

oFld.value = 0;

else

oFld.value += 1;

The above code checks to see if  one Is on the template page or a spawned page from the template and adjust the prefix as needed.

kareng26030666
Participating Frequently
May 1, 2017

Yes I have tried different prefix adjustments in the template and checked after spawning. Sadly none have worked.

Bernd Alheit
Community Expert
Community Expert
April 29, 2017

Where do you use the variable "prefix" ?