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

Consecutive letters text field

New Here ,
Jun 29, 2022 Jun 29, 2022

Copy link to clipboard

Copied

Trying to create multiple text fields with consecutive letting based on user input of text box 1. 

For example

If user enters "A" in text box 1, text box 2 will auto populate "B" and text box 3 will have "C",  and so fourth. At the end of the alphabet, after "Z", it would auto populate "AA".

Can someone help me out please, I've been searching for hours with no luck.

TOPICS
JavaScript

Views

1.0K

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
Community Expert ,
Jun 29, 2022 Jun 29, 2022

Copy link to clipboard

Copied

Doing it up to "Z" is not too difficult, but then it becomes a bit tricky. How many such fields do you have?

Votes

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 ,
Jun 30, 2022 Jun 30, 2022

Copy link to clipboard

Copied

@try67 It differs depening on the day, sometimes I'll have 5 fields, sometimes it can go up to 180+. If you can show me how to do it up to "Z" I can write in the other letter after it doubles up.

 

Thank you so much

Votes

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
Community Expert ,
Jun 30, 2022 Jun 30, 2022

Copy link to clipboard

Copied

This is not my code, I found it online (and tweaked it a bit), but it seems to work pretty well:

 

function colName(n) {
	var ordA = 'a'.charCodeAt(0);
	var ordZ = 'z'.charCodeAt(0);
	var len = ordZ - ordA + 1;
  
	var s = "";
	while(n >= 0) {
		s = String.fromCharCode(n % len + ordA) + s;
		n = Math.floor(n / len) - 1;
	}
	return s.toUpperCase();
}

Votes

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 ,
Jun 30, 2022 Jun 30, 2022

Copy link to clipboard

Copied

this is the error code im getting

SyntaxError: syntax error
1:Console:Exec
undefined

 

I still don’t get how to make this work efficiently. This is what I’m trying to do. I have a drop down list with 5 different choices, option 1, option 2, option 3, option 4, option 5. I have 40 different text fields, each named sequentially, Exhibit1, Exhibit 2, Exhibit 3, and so fourth.

If option 1 or option 3 is selected, and the number 1 is typed into Exhibit1, then I want 2 to automatically show up in Exhibit2, and 3 in Exhibit3. If the number 5 is typed into Exhibit1, then I want 6 to automatically show up in Exhibit2, and 7 in Exhibit3.

If option 2 or option 4 is selected, I would like the same as above but with consecutive letters, if letter A in Exhibit1, letter B in Exhibit 2. If K in Exhibit1, L in Exhibit2, M in Exhibit 3.

Votes

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

Copy link to clipboard

Copied

I'm not sure did you wanted to continue after 'Z' with 'AA','BB','CC'...etc or 'AA','AB','AC'...etc.

Anyway I set it so it's 'AA','BB' and when reach 'ZZ' it will continue with 'AAA' up to 'ZZZZZZ', numbers are set up to 1000, you can change it easily if you need higher numbers.

Use it as custom calculation script in one of the fields:

var num  = [];
for(var j=1; j<=1000; j++){num.push(j);}
var a0 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
var a1 = [],a2 = [],a3 = [],a4 = [],a5 = [];
for(var z in a0){
a1.push(a0[z]+a0[z]);
a2.push(a0[z]+a0[z]+a0[z]);
a3.push(a0[z]+a0[z]+a0[z]+a0[z]);
a4.push(a0[z]+a0[z]+a0[z]+a0[z]+a0[z]);
a5.push(a0[z]+a0[z]+a0[z]+a0[z]+a0[z]+a0[z]);}
var alpha = a0.concat(a1,a2,a3,a4,a5);

var x = this.getField("Exhibit1");
var ord1 = num.indexOf(Number(x.value));
var ord2 = alpha.indexOf(x.valueAsString);
var drop = this.getField("Dropdown").valueAsString;

for(var i=2; i<= 40; i++){
if((drop == "option 1" || drop == "option 3") && (x.valueAsString != "" && typeof x.value == "number"))
this.getField("Exhibit"+i).value = num[i+ord1-1];
else if((drop == "option 2" || drop == "option 4") && (x.valueAsString != "" && typeof x.value == "string"))
this.getField("Exhibit"+i).value = alpha[i+ord2-1];
else{
this.getField("Exhibit1").value = "";
this.getField("Exhibit"+i).value = "";}}

And just to be sure if someone enter lowercase character, as 'Validation' script of "Exhibit1" field use this:

if(event.value && typeof event.value == "string")
event.value = event.value.toUpperCase();

 

Votes

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 05, 2022 Jul 05, 2022

Copy link to clipboard

Copied

I just tried this and it did not work. Not sure what I'm doing wrong.

Votes

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

Copy link to clipboard

Copied

It's setup for 40 fields named "Exhibit" and dropdown field named "Dropdown" with choices 'option 1' through 'option 5'.

If you can share your file I can take a look at it.

Votes

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 05, 2022 Jul 05, 2022

Copy link to clipboard

Copied

I finally got it, had to go through and rename all the exhibit tags and made sure there were no spaces.

 

Quick question. If I were to have another option for the drop down, would I just add

a6.push(a0[z]+a0[z]+a0[z]+a0[z]+a0[z]+a0[z]+a0[z]);}
after the 
a5.push(a0[z]+a0[z]+a0[z]+a0[z]+a0[z]+a0[z]);}

also if I had more than 40 Exhibits, would the 

for(var i=2; i<= 40; i++)

chance to 

for(var i=2; i<= 60; i++) or whatever number I need?

 

Thank you so much

Votes

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 ,
Apr 19, 2024 Apr 19, 2024

Copy link to clipboard

Copied

LATEST

I am using adobe designer. How do I incriment a field (Count) in a repeatable subform with letter as I add new instances of that subform. The field I am updating is the first filed in a line of fields.

 

Eg.

 

A. 

B. 

C. 

D. 

 

Joe368587850czc_0-1713556602253.png

The Sub Form is (topmostSubform.Page_1.Para3.Interviewed_Personnel_subform) and the Field I want to update is 

topmostSubform.Page_1.Para3.Interviewed_Personnel_subform.Count. I use the "+" to create a new instance of (Interviewed_Personnel_subform) and that is when I want the new instance of (Count) with the next letter.

Votes

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