Skip to main content
Known Participant
April 26, 2022
Answered

Checkboxes not working on a spawned page

  • April 26, 2022
  • 3 replies
  • 2412 views

Here is my code for the spawned page

var SpawnPage = this.getTemplate({cName: "table"});
  SpawnPage.spawn({nPage: this.numPages, bRename: true, bOverlay: false});
    this.getField("P" + (this.numPages - 1) + ".table.Name").setFocus();

The code for the checkbox looks like this:

var nDisplay = event.target.isBoxChecked(0) ? display.visible : display.hidden;
this.getField("P" + (this.numPages - 1) + ".table.Dropdown39").display = nDisplay;
this.getField("P" + (this.numPages - 1) + ".table.Text40").display = nDisplay;
this.getField("P" + (this.numPages - 1) + ".table.Text41").display = nDisplay;

Unfortunatelly it doesn't work. I have no idea how I should link the checkbox to the correct element on the spawned page...

This topic has been closed for replies.
Correct answer try67

Then use event.target.page instead of this.numPages-1. For example:

 

this.getField("P" + (event.target.page) + ".table.Text41").display = nDisplay;

3 replies

Bernd Alheit
Community Expert
Community Expert
April 27, 2022

Can you share the form?

Known Participant
April 28, 2022

Plese find a form attached. I have deleted all not needed information and left only the objects that are causing the problem.

Known Participant
April 28, 2022

PS. ON/OFF button is for the purpose when checkbox won't be working. In that case I would have to leave the buttons then, but I would really like to have the checkboxes working instead of those buttons.

try67
Community Expert
Community Expert
April 26, 2022

Is the purpose of the check-box to show/hide fields on the same page as it is, or on another page?

Known Participant
April 27, 2022

On the same page.

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
April 27, 2022

Then use event.target.page instead of this.numPages-1. For example:

 

this.getField("P" + (event.target.page) + ".table.Text41").display = nDisplay;

Bernd Alheit
Community Expert
Community Expert
April 26, 2022

Check the Javascript console for errors.

Known Participant
April 26, 2022

I thought that maybe it has to do something with this line: 

this.getField("P" + (this.numPages - 1) + ".table.Text41").display = nDisplay;

I guess that it points everytime on the element that is spawned. In that case if I have this element at the top of every spawned page and it is named P4.table.Text41, P5.table.Text41, P6.table.Text41, etc. if I check one checkbox, that top element on every spawned page is checked. How to avoid this?