473,322 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Random Reference Number

Jacotheron
I want to create a javascript that is able to randomly generate a 7 digit number and fill it in a textbox that is unchangeable. It should not repeat the same number before all of the possible numbers has already been used.

Can someone please help??
Jan 14 '08 #1
9 1318
acoder
16,027 Expert Mod 8TB
Unless you store all previous numbers, this won't be possible.

Use Math.random() for the randomization. Note that it gives a number between 0 and 1. To get a useful number between 1 and something, use something like Math.floor(Math.random()*maxNum+1).
Jan 15 '08 #2
Unless you store all previous numbers, this won't be possible.

Use Math.random() for the randomization. Note that it gives a number between 0 and 1. To get a useful number between 1 and something, use something like Math.floor(Math.random()*maxNum+1).
How would I store the previous numbers that it can't be used again in the next 30 days. With the "Math.floor(Math.random()*maxNum+1)" I supose I can get it right.

Thank you for your help
Jan 15 '08 #3
gits
5,390 Expert Mod 4TB
hi ...

in case you store it in a database you could retrieve all the used numbers on pageload and build a lookup list with it ... another way would be a cookie at the clientside ... but i would prefer the db-way :)

kind regards
Jan 15 '08 #4
hi ...

in case you store it in a database you could retrieve all the used numbers on pageload and build a lookup list with it ... another way would be a cookie at the clientside ... but i would prefer the db-way :)

kind regards
How do I create a database that the client browser can add the number automaticly. (I have very little experience in javascript as you might have noticed).

Thanx for the help
Jan 16 '08 #5
acoder
16,027 Expert Mod 8TB
How do I create a database that the client browser can add the number automaticly.
A database would require server-side coding. Which language are you using on the server-side?
Jan 16 '08 #6
A database would require server-side coding. Which language are you using on the server-side?
I can't yet use any serverside code, but would try to do something about that (I am the same person of the "Bookings manager" and this client have selected the Micro option too, like every body else).

I should have a reply about tomorrow (18 January 2008) about server side code.
Jan 17 '08 #7
acoder
16,027 Expert Mod 8TB
I can't yet use any serverside code, but would try to do something about that (I am the same person of the "Bookings manager" and this client have selected the Micro option too, like every body else).
Yes, I noticed. You'll have to try to convince them. If they don't agree, you can use cookies, but that would only be random for that one person (not across al people using the system) and I think cookies have a size limit.
Jan 18 '08 #8
Yes, I noticed. You'll have to try to convince them. If they don't agree, you can use cookies, but that would only be random for that one person (not across al people using the system) and I think cookies have a size limit.
Well, thanx for the help, even as I was not successful with this.
Jan 18 '08 #9
acoder
16,027 Expert Mod 8TB
Well, thanx for the help, even as I was not successful with this.
You weren't successful in convincing them that they needed server-side code? Sometimes clients need to know that things are simply not possible the way they see it. This can only be done on the server-side. JavaScript is great at what it does, but it's limited (for a reason).
Jan 18 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Brandon Michael Moore | last post by:
I'm trying to test a web application using a tool written in python. I would like to be able to generate random values to put in fields. I would like to be able to generate random dates (in a...
23
by: Thomas Mlynarczyk | last post by:
I remember there is a programming language where you can initialize the random number generator, so that it can - if you want - give you the exactly same sequence of random numbers every time you...
4
by: Jack | last post by:
I have two files: sort_comparison.c++ my_sort.h sort_comparison.c++ calls this code in my_sort.h: void my_sort::fillArray(int arr,int n) { // const int random_number_range=1000000;
10
by: Johnny Snead | last post by:
Hey guys, Need help with this random sort algorithm private void cmdQuestion_Click(object sender, System.EventArgs e) { Random rnd = new Random(); //initialize rnd to new random object...
16
by: Leon | last post by:
I need a program that generate 5 non-duplicates random number between 1-10 as string values store in an array. Do anybody know of any good books or websites that explain how to generator random...
15
by: Papajo | last post by:
Hi, This script will write a random number into a document write tag, I've been trying to get it to write into a input form box outside the javascript, any help is appreciated. Thanks Joe ...
12
by: Pascal | last post by:
hello and soory for my english here is the query :"how to split a string in a random way" I try my first shot in vb 2005 express and would like to split a number in several pieces in a random way...
9
by: Chelong | last post by:
Hi All I am using the srand function generate random numbers.Here is the problem. for example: #include<iostream> #include <time.h> int main() {
26
by: bilgekhan | last post by:
What is the correct method for generating 2 independent random numbers? They will be compared whether they are equal. What about this method: srand(time(0)); int r1 = rand(); srand(rand());...
13
by: Nick | last post by:
Hi there, I'm trying to create a random number via a seed in VB.NET and C++, 2 different applications. I want to be able to use the same seed and get the same random number but unfortunately...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.