Click to See Complete Forum and Search --> : Random 10 digit number...


drymetal
01-25-2007, 05:33 PM
A friend of mine has a website on home security. He has created a part for people to be dealers for his company and to make a long story short...somehow I got involved...and the guy from an affiliate company that is going to track the dealers sales sent me this note:

thanks Larry. Hi Chad, can you insert the following code into the Confirmation Page ? This page is displayed after the person clicks on the web inquiry form.

<img src="http://coldfusion.affiliateshop.com/WIDLink.cfm?WID=001545&Pending_Sale=1&OrderID=<?=$SubmissionID?>" width="1" height="1">

You have to create a unique number each time a form is submitted. It is like a Receipt Number or Invoice Number. A common way to generate this unique ID is through a concatenation of date and time and a random 10 digit number. E.g. "2006-12-02-0800-9288919286""

This variable should not have spaces.

Let me know if you have any additional questions.

-Well, I had a question. How in the world do I generate a random number like that? What in the world is a concatenation? So he replied and told me that he could send a script for only seventy five dollars! My Lord.

So, I'm hoping that someone here could tell me how to generate this code on the form page? Thanks in advance...

NogDog
01-26-2007, 12:08 AM
This cannot be done within HTML, but will require either some JavaScript on the client side, or some server-side scripting (PHP, Perl, ASP/.NET, etc.) If JavaScript, you need to keep in mind that some small percentage of your users may not have JS enabled. If you opt for server-side, then you'll first need to ascertain which scripting language(s) your web host supports. Once you've made that choice (between JS or server-side scripting), you can ask for help in the appropriate forum here.

jalarie
01-26-2007, 07:25 AM
If you decide to use client-side JavaScript, the following gives you a place to start:

RN=Math.floor(Math.random()*9999999999);
while (String(RN).length < 10) {
RN='0'+RN;
}
alert(RN);

Tweak4
01-26-2007, 02:43 PM
Of course, using Javascript for the whole thing would generate a string starting with the date as it is set on the user's pc. There is no guarantee that their pc is set correctly, so if the correctness of the date matters at all, a server-side solution might be better.
Regardless of the solution you choose, the actual code should be pretty simple.