Getting a random ID put on a page

Hey all,

I am wanting something to generate a unique 5 digit ID, like Ah45P or something along those line.

Heres my set up, someone comes to the site, fills out a form, they go to a thank you page, then they see “click to get your Unique ID”, upon click they go to another page that says… “Your Unique ID is 12345” . (hope that made sense)

Is there any tutorials that I can do that with?

Hi there,

This will do what you want:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Generate unique ID</title>

    <p>Your unique ID is: <span id="uniqueID"></span></p>

      function makeid(){
        var text = "";
        var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
        for( var i=0; i < 5; i++ ){
          text += possible.charAt(Math.floor(Math.random() * possible.length));
        return text;

      document.getElementById("uniqueID").innerHTML = makeid();

I’m afraid I can’t take credit for it though, it’s lifted straight from Stack Overflow:
Where there is a good discussion of the best way to do this.

Hope that helps.

Worked perfect.

Thank You