How to generate alpha numeric numbers using java script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mail2pragati
    New Member
    • Aug 2007
    • 1

    How to generate alpha numeric numbers using java script

    Hellp all,
    I want to generate the alpha numeric numbers (like : A-0001/0708,S-0010/0708) as soon as the form is loaded. Is it possible using Java Script. And then these generated numbers are stored in Data Base. n it sh not generate the same number again.
    Thanks in advance
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    Originally posted by mail2pragati
    Hellp all,
    I want to generate the alpha numeric numbers (like : A-0001/0708,S-0010/0708) as soon as the form is loaded. Is it possible using Java Script. And then these generated numbers are stored in Data Base. n it sh not generate the same number again.
    Thanks in advance
    Welcome to TSDN.
    Generate the Alpha Numeric numbers is possible in JavaScript.
    But store those data you need to write Server Side Code.
    Try some code then come with Code Tags here with specific Code.
    And remember one thing don't use Code Words while you post something here.
    This is a forum not a Chat Room.
    Anyway, Good luck with your try.

    Kind regards,
    Dmjpro.

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Originally posted by mail2pragati
      I want to generate the alpha numeric numbers (like : A-0001/0708,S-0010/0708) as soon as the form is loaded. Is it possible using Java Script. And then these generated numbers are stored in Data Base. n it sh not generate the same number again.
      This is possible using Javascript, but you want a unique number each time and you wish to store them in a database. For something like this, it would be much better to use a server-side language.

      Comment

      • pbmods
        Recognized Expert Expert
        • Apr 2007
        • 5821

        #4
        Heya, Pragati. Welcome to TSDN!

        When you think about it, 'letters' are really just ASCII codes, which are in turn integers.

        JavaScript has a Math.random() function that can generate a random number, and then to convert that number into a character, you simply use String.fromChar Code().

        The trick is to figure out how to get your random numbers so that you are only creating characters between 0 and Z. Fortunately, there are lots of ASCII charts out there... :)

        Comment

        Working...