Code won't persist after Save
Scenario: I'm building a form to track production over the week. A series of text fields for different widgets, with odd numbers (Widget A = Text1, WidgetB = Text3, Widget C = Text5). I have a series of buttons to increment the text field up and down, numbered sequentially (Button1, Button2, Button3, Button4, Button5, Button6). In the end i'm going to have over 125 text fields, and 250 buttons. I wrote a for loop that with the click of the "goButton" will write the script to all of those buttons for me. Right now I only have 3 text fields and 6 buttons until proof of concept, before I make this gigantic pdf.
Problem: The button and the script work perfectly as intended, however they do not persist after a save and a close. I would have to click the "goButton" every time I open it to insert the script into the buttons again. My first instinct is that the individual buttons only have a function in their javascript and not the actual script. It works, but it doesn't work right... Any help is appreciated
"goButton" Mouse Up event looks like this:
//increment text field up
function foo(i) {
var x = this.getField("Text" + i).value;
x += 1;
this.getField("Text" + i).value = x;
}
//increment text field down, don't go below zero
function bar(i) {
var x = this.getField("Text" + i).value;
if(x>0) {
x-= 1;
}
this.getField("Text" + i).value = x;
}
var myButton1="";
var myButton2="";
for(i=1;i<7;i+=2){
//odd number buttons
myButton1 = this.getField("Button" + i);
myButton1.setAction("MouseUp","foo("+i+")");
myButton1.setCaption("+");
//even number buttons
var j = i+1;
myButton2 = this.getField("Button" + j);
myButton2.setAction("MouseUp","bar("+i+")");
myButton2.setCaption("-");
}
