12,506,584 members (53,782 online)
Rate this:
See more:
My problem is that I have been trying to make a letter increment as such:

a-b-c-d etc then when it gets to z go: aa-ab-ac-ad... ba-bb-bc-bd and so on.

And if any user simply input the latter a, it should be give output 1 and z-26, and so on

For Example-
User input a then output should be 1
User input z then output should be 26
User input aa then output should be 27

This series will go upto zz
<

If anyone knows a simple solution to this please respond. I will keep trying but not seccess.
Posted 16-Feb-13 19:35pm
Sandeep Mewara 17-Feb-13 2:03am

It does not work like this here.

Here is what is expected of enquirers:
1. TRY first what you want to do! You may find that it's not that hard.
2. Formulate what was done by you that looks like an issue/not working.

Try them and tell if you face issues.
Members will be more than happy to help like this.
riteshsingh_jsr 17-Feb-13 2:06am

How can I increment the loop after z... I have displayed a-z only how can I display aa to zz

Rate this:

## Solution 2

This smells like homework, so I will give you no code!
However, it really isn't a complex task:

1) Set up a loop - this can be a "while true" loop
3) If the input is blank (I would use string.IsNullOrWhitespace for this) exit the loop.
4) Initialize a sum to zero.
5) For each character in the input string, go round another loop
5.1) If the character is between 'a' and z' inclusive,
5.1.1) Multiply the sum by 26.
5.1.2) Subtract 'a' from the character, and add one (this converts a to 1, b to 2 and so on)
5.1.4) Go round the character loop at (5)
6) Print the sum
7) Go back round the loop at (2)
Rate this:

## Solution 1

This will work for you

65 = "A".charCodeAt(0);
66 = "B".charCodeAt(0);
OriginalGriff 17-Feb-13 2:57am

Reason for my vote of one: Read the question. This does not answer it or even begin to answer it!
riteshsingh_jsr 18-Feb-13 6:15am

Sorry dear, i was not able to understand your solution.
Rate this:

## Solution 3

Sorry dear it's my new code according to your question it's working fine according to me, if you feel any issue there you can contact to me syedasim8@hotmail.com

```function GetValues() {
var val = document.getElementById('<%=TextBox1.ClientID %>').value;
var alphaArray = "abcdefghijklmnopqrstuvwxyz";
var totalChars = alphaArray.length;
var index = 0;
var subtotal = 0;
if (val.length == 1) {
index = alphaArray.indexOf(val) + 1;
}
else if (val.length == 2) {
var firstChar = val.substring(0, 1);
var secondChar = val.substring(1, 2);
var charPosition = totalChars * (alphaArray.indexOf(firstChar) + 1);
index = (alphaArray.indexOf(secondChar) + 1) + charPosition;

}
document.write(index);
}```

Please don't forgot to give me points.
Thanks
v2

Top Experts
Last 24hrsThis month
 OriginalGriff 308 David_Wimbley 194 Karthik Bangalore 181 Richard MacCutchan 128 Richard Deeming 120
 OriginalGriff 7,406 ppolymorphe 3,984 Maciej Los 3,751 David_Wimbley 3,106 Karthik Bangalore 3,052