Keep getting undefined

New Here ,
Jul 25, 2022 Jul 25, 2022

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} }
TOPICS
General troubleshooting , JavaScript

Views

69

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
community guidelines
New Here ,
Jul 25, 2022 Jul 25, 2022

Copy link to clipboard

Copied

1600 text field 

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
community guidelines
LEGEND ,
Jul 25, 2022 Jul 25, 2022

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. 

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
community guidelines
New Here ,
Jul 26, 2022 Jul 26, 2022

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. 

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
community guidelines
LEGEND ,
Jul 26, 2022 Jul 26, 2022

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. 

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
community guidelines
New Here ,
Jul 26, 2022 Jul 26, 2022

Copy link to clipboard

Copied

20220726_053541.jpg

20220726_053920.jpg

 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

quote

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.

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
community guidelines
Adobe Community Professional ,
Jul 26, 2022 Jul 26, 2022

Copy link to clipboard

Copied

At addField use a other field name.

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
community guidelines
New Here ,
Jul 27, 2022 Jul 27, 2022

Copy link to clipboard

Copied

20220727_070748.jpg

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? 

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
community guidelines
Adobe Community Professional ,
Jul 27, 2022 Jul 27, 2022

Copy link to clipboard

Copied

LATEST

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...

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
community guidelines
Adobe Community Professional ,
Jul 25, 2022 Jul 25, 2022

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...

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
community guidelines
Adobe Community Professional ,
Jul 26, 2022 Jul 26, 2022

Copy link to clipboard

Copied

Where does you use the script?

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
community guidelines