Copy link to clipboard
Copied
I have over 1600 over different pages that I need to have different values. I try to use this code I found online. undefined keeps popping up every time. Can I get help?
for (var i=0;i<200;i++) { try{ var rct=this.getField("Name1."+i).rect; var pg=this.getField("Name1."+i).page; this.addField("name."+i,"text",pg,rct); }catch(e){break} }
Copy link to clipboard
Copied
1600 text field
Copy link to clipboard
Copied
What do you mean by "undefined keeps popping up"? It's normal and not an error, in the console, for example.
Copy link to clipboard
Copied
I'm not a programmer so trying to figure this out is pretty hard for me. I'm trying to change all the text fields name that have the same name to a different one so they won't have the same value. I took out catch(e){break} to see if they're any error. The only thing that pops up is undefined and nothing happens.
Copy link to clipboard
Copied
Ok, you've just come round to "undefined pops up". We don't know what you mean, but in programming every detail matters. So please share a screen shot of what you see.
Also, what are the current, exact field names, and what is the exact effect you want to have. Not roughly, but exactly. It's the only thing that makes sense in programming, we can't guess anything about what you want to do.
Copy link to clipboard
Copied
I had made a text field with the name StartDatePage and duplicate it across 35 different pages. Later on I was going to make multiple copies of those text field so I can fill in the rest of the spots. The problem I've been having is that because they are the same name they'll have the same texted when I type something in. so I'm trying to make all the "StartDatePage" have a different name/value. I
Ok, you've just come round to "undefined pops up". We don't know what you mean, but in programming every detail matters. So please share a screen shot of what you see.
Also, what are the current, exact field names, and what is the exact effect you want to have. Not roughly, but exactly. It's the only thing that makes sense in programming, we can't guess anything about what you want to do.
By @Test Screen Name
found this code online that I thought it would do the trick. The plan was to use a for loop to add number to the old text field name. Then create a new text field with the new name. Im going to removed all the old text fields with this this.removeField("StartDatePage"). I ran the code and nothing happens and undefined pops up. Hope thats descriptive enough. I'm not that good at explaining things.
Copy link to clipboard
Copied
At addField use a other field name.
Copy link to clipboard
Copied
The name of the field had not changed after I changed the .addfield name to HI. im still getting undefined. I added space to the var and addfields lines. Now I'm it shows "i " is not defined. Any recommendations?
Copy link to clipboard
Copied
The addField method doesn't change a field's name. It adds a new field.
And are you selecting the full code before executing it? I think you're only running one line each time...
Copy link to clipboard
Copied
If you want to locate errors in your code the first step is to remove the try-catch clause which hides them from you, or at the very least add a command to the catch part which prints out the error message that triggered it...
Copy link to clipboard
Copied
Where does you use the script?