Highlighted

Having trouble Coping and Pasting Buttons from different forms

Community Beginner ,
Jul 20, 2020

Copy link to clipboard

Copied

A while ago I created a form with custom Buttons which changed their caption and fill colour when clicked on, and a Reset Button which would clear them up through a script, as this.resetForm(); wasn't enough. It works fine; however, I copied the same buttons into a different version of the same form (changed language and BG pictures), and now the Reset Button doesn't work with them.

 

This is what is on the Reset Button:

var USure = app.alert ("You are about to RESET this Form,\n\n" + "¿Are you SURE you want to do this?", 1, 2);
if(USure == 4) 
{
	this.resetForm();
	
	var bSwitch1 = this.getField("bSwitch1");
	var bSwitch2 = this.getField("bSwitch2");
	var bSwitch3 = this.getField("bSwitch3");

	bSwitch1.buttonSetCaption("");
	bSwitch2.buttonSetCaption("");
	bSwitch3.buttonSetCaption("");

	this.getField("bSwitch1").fillColor = color.trasparent;
	this.getField("bSwitch2").fillColor = color.trasparent;
	this.getField("bSwitch3").fillColor = color.black;
}

 

this is what is on the Switch buttons:

(function () {
    // Get this button's current caption
    var val = event.target.buttonGetCaption(); 

    // Set caption to the next one in the loop
    switch (val) {

    case "X" :
        event.target.buttonSetCaption("");
        event.target.fillColor = color.transparent;
        break;

    case "/" :
        event.target.buttonSetCaption("X");
        event.target.fillColor = color.black;
        break;

    case "" :
        event.target.buttonSetCaption("/");
        event.target.fillColor = color.transparent;
        break;
     }
})();

 They have the same names and sizes, behaivours, etc. Why is this happening?

 

Thank you very much in advance for your help!

TOPICS
How to, PDF forms

Views

74

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Having trouble Coping and Pasting Buttons from different forms

Community Beginner ,
Jul 20, 2020

Copy link to clipboard

Copied

A while ago I created a form with custom Buttons which changed their caption and fill colour when clicked on, and a Reset Button which would clear them up through a script, as this.resetForm(); wasn't enough. It works fine; however, I copied the same buttons into a different version of the same form (changed language and BG pictures), and now the Reset Button doesn't work with them.

 

This is what is on the Reset Button:

var USure = app.alert ("You are about to RESET this Form,\n\n" + "¿Are you SURE you want to do this?", 1, 2);
if(USure == 4) 
{
	this.resetForm();
	
	var bSwitch1 = this.getField("bSwitch1");
	var bSwitch2 = this.getField("bSwitch2");
	var bSwitch3 = this.getField("bSwitch3");

	bSwitch1.buttonSetCaption("");
	bSwitch2.buttonSetCaption("");
	bSwitch3.buttonSetCaption("");

	this.getField("bSwitch1").fillColor = color.trasparent;
	this.getField("bSwitch2").fillColor = color.trasparent;
	this.getField("bSwitch3").fillColor = color.black;
}

 

this is what is on the Switch buttons:

(function () {
    // Get this button's current caption
    var val = event.target.buttonGetCaption(); 

    // Set caption to the next one in the loop
    switch (val) {

    case "X" :
        event.target.buttonSetCaption("");
        event.target.fillColor = color.transparent;
        break;

    case "/" :
        event.target.buttonSetCaption("X");
        event.target.fillColor = color.black;
        break;

    case "" :
        event.target.buttonSetCaption("/");
        event.target.fillColor = color.transparent;
        break;
     }
})();

 They have the same names and sizes, behaivours, etc. Why is this happening?

 

Thank you very much in advance for your help!

TOPICS
How to, PDF forms

Views

75

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 20, 2020 0
Most Valuable Participant ,
Jul 20, 2020

Copy link to clipboard

Copied

So what happens when you press the button, exactly?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 20, 2020 0
Community Beginner ,
Jul 20, 2020

Copy link to clipboard

Copied

the Buttons stay the same. If their value was X or Black, they stay that way when it should go transparent and caption should be empty.

The original form is fine, but when copied into a new file the Reset button doesn't affect them. The buttons work per se, it's the Reset which has problems.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 20, 2020 0
Most Valuable Participant ,
Jul 21, 2020

Copy link to clipboard

Copied

Check the JS Console for error messages.

If you want you can share the file with us and we could check it for you.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 21, 2020 0
Community Beginner ,
Jul 21, 2020

Copy link to clipboard

Copied

Okay, this is what shows...

 

Falcongaze_0-1595358335321.png

and you can find the file down here

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 21, 2020 0
Community Beginner ,
Jul 21, 2020

Copy link to clipboard

Copied

File I'm having trouble 

 

didn't know how to share it here, so Onedrive!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 21, 2020 0
try67 LATEST
Most Valuable Participant ,
Jul 21, 2020

Copy link to clipboard

Copied

There are no fields called "bSwitchX" in this file...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 21, 2020 0