Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Keep getting undefined

New Here ,
Jul 25, 2022 Jul 25, 2022
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
3.2K
Translate
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

1600 text field 

Translate
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

What do you mean by "undefined keeps popping up"? It's normal and not an error, in the console, for example. 

Translate
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

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. 

Translate
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

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. 

Translate
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

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.

Translate
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
Community Expert ,
Jul 26, 2022 Jul 26, 2022

At addField use a other field name.

Translate
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

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? 

Translate
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
Community Expert ,
Jul 27, 2022 Jul 27, 2022
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...

Translate
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
Community Expert ,
Jul 25, 2022 Jul 25, 2022

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

Translate
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
Community Expert ,
Jul 26, 2022 Jul 26, 2022

Where does you use the script?

Translate
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