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!
Copy link to clipboard
Copied
So what happens when you press the button, exactly?
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.
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.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
There are no fields called "bSwitchX" in this file...