SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    alphabet question

    hi!
    i have an array of letters from a to z...
    so i start with A, B. C etc...
    now when the number of cols is greater then alphabetic letters i want to get
    AA, AB, AC etc...
    is there a simply way to do it?
    any suggestion appreciated!
    thanx in advance!

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok...
    i get the y valuie from for loop....
    hth
    Code:
              if(y > 26) {
              table += xrrayK[y.substr(0, 1)]+xrrayK[y.substr(1, 1)];
              } else {
              table += xrrayK[y];
              }
    and this wont work couse i use substr into array key....
    when i left only y then work but it is not the result i want...
    any suggestion why this wont work?
    thanx in advance!

  3. #3
    SitePoint Zealot
    Join Date
    Dec 2004
    Location
    Finland
    Posts
    103
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This one works for range 1..701:
    Code:
    function alpha(n) {
     if (n<27) return String.fromCharCode(64+n);
     if (n<27*26) return String.fromCharCode(64+n/26)+String.fromCharCode(65+n%26);
    }

  4. #4
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wow man....
    u deserved a drink for this function!!!!
    cheers


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •