Unique Random Number
How can I generate a unique random number?
View RepliesHow can I generate a unique random number?
View RepliesI have to develop an online quiz on my website. the site is developed in ASP.
i have a access database of the questions, the multiple ans.s and the correct ans. every quest. has an unique id.
i want a way by which any 10 'unique' quests. will be selected from the database everytime an user takes the test.
I am trying to get random, unique pics to display but for some reason, I sometimes get the same pics showing twice.
could someone kindly shed some light on this Code: ...
I have a database with 20 companies and their links in it. Ive tried to develop some code that i found in another forum while i was searching for a solution to 'unique random links' but, although i feel im close, Code:
View Replies View RelatedI have a web page that submits a form to a database. Each time a form is submitted, I need to assign it a unique case number and insert the case number into the database along with the information entered in the form.
I am able to insert all the data into the database, but am not sure how to generate the case number to insert. Is there a way to do this based on number from the previous entry, like just add 1 to it?
I am trying to generate a random number. I am using randomize and then rnd to return a decimal number between 100 and 120. This will give me a longitude. I am doing something similar to generate a latitude.
I created this on a page which refreshs every minute. I put these points into a map and they are showing up in groups of straight lines. Since rnd is time based will refreshing every 60 seconds return similar numbers?
trying to get a random number from 0000 to 9999, is there an easy way to do this? i'm using this for a unique filename and want it to be 4 digits from 0000 to 9999.
View Replies View Relatedx = ROUND((0.9+1.005*RND()-0.4),1)
y = INT(y * x)
This is what I'm trying to acheive:
- "Y" has a preset value between 1-100
- "X" should be random between 0.8 and 1.2
- "X * Y" is the final value of "Y" as a whole number
What I'm struggling with is getting the value of X to be random between 0.8 and 1.2....
How would you go changing a random number generated into a item drawn from a database with SQL....
View Replies View RelatedI need to create a random number, or even better, and random combination of letters and numbers, to be used as a type of security key for changing a user's password on this site i'm working on. Basically, the user fills out this form which sends them and e-mail w/ instructions on how to change their password (pretty basic, lots of sites do it).
In the e-mail of course is a link which links to a page with querystring values that include their customer number, the action (reset password), and hopefully this "key." What I'd like to do is have the key written to a database when the e-mail is sent and then deleted when the password is changed. So, how can I generate this key. I think I can take care of the writing to/deleting from the database.
I'm trying to create a random number that has to solid letters at the beginning followed by 8 random numbers (DN13523781) This number also can't be in use alreaddy which means it can't alreaddy be in a colum called number in the database.
I can do the letters followed by one number, but I can't figure out how to get 8 numbers in a row without getting the same ones over and over(88888888)
I also don't know how to check if it's alreaddy used in the database.
Also does someone know how I can prevent the same number from being produced before it can be added to the database at an other location/pc.
I'm building an online store and I want to give people an order number when they order something. Code:
Does anyone know of any parameters for either of these functions?
Say, if I wanted only numbers between 1 and 100?
Code:
<%
randomize()
response.write(rnd())
%>
I've got a realy wierd server problem - everytime i ask for a random number using rnd() i get 0.7055475. This problem just appeared the other day. I hadnt changed any server or os settings, however i have recently recieved a 6 part xp pro update... - has anybody come accross this before?
View Replies View RelatedI want to display a random banner from a selection of 5 banners. So if number = 1 then display baner 1 etc. My code is as follows:
bannerCount = bannerRecordSet.RecordCount
Dim bannerSelected
Randomize
bannerSelected = Int(Rnd * bannerCount)
The above code works although it never seems to generate the value 1, ie 2-5. Also when I refresh the page sometimes a random banner is displayed and other times I get an error. Is this because I am generating a value outside 1-5? Code:
Does anyone know how to code in a very simple random number generator?
Basically, my ASP site is linked to an SQL d/base. What I want to do is have a "Random quote of the day"... the R.N.G. should spit out a number, and that number references the random_quote_ID in the d/base and spits it out.
I have this simple application that I put together using ASP. It has an html form that submits to an access database through a simple ASP file. It’s a survey form basically. One of the departments here wants to get some feedback from their students and in return for filling out the survey they will be entered into a drawing for a gift certificate. The catch is that the survey is anonymous. What they want to happen is each person is given a unique number at the end of the survey and they will pick one of those numbers randomly to see who the winner is. How can I possibly do this? I am stuck.
I think I may know what I need to do:
Pull a unique number from a database and post it onto the HTML form near the submit button. Notate on the page that the user write the number down and when they hit submit it is inserted into the database along with the record. I have absolutely no idea how to do that.
The HTML form submits into the database using this "add.asp" file:
Code: ....
I've tried using javascript to rotate an image upon reload, but I can't get it working, so now I'm trying it with asp. I don't understand why this won't work. Any ideas? Code:
View Replies View RelatedI want to create a random number where it concatenates with the "day counter" as explained below and name of the person inorder to generate a unique id.
by day counter i mean. there are 365 days in a year and today is the 18th day of the yeat. so the counter generated shud be 18&Smilesmita. How do i do this in ASP ?
I know this is not a php forum, but i've been given a task to create a form that requires a unique number every time the form is loaded. The form has been created but they have php on their site. windows would be in 3 weeks time but they want the form asap. The field is a hidden field since i've never looked at a php code page b4 i need some help.
View Replies View RelatedI have used:
set typ = server.createobject("Scriptlet.TypeLib")
to create a random string of 36 characters. However, is there a way to
create a random string of digits in the length I request? Perhaps a string
of 20 digits with a few asterisks thrown in for ease of typing?
for example:
4515-81301-75454-45136-1
Would this be reated with RegExp? And how?
not after code, just thoughts, suppose i'm generating a random 8-digit pin number for our clients, first i'll be checking against the db to see if it already exists before assigning it. what i might do for that is getstring all of the exsiting pins at the top of the script and just keep performing an instr until i get a 0. (i dont expect to ever go above a thousand clients for this system and hopefully my initial number will be random enough that these checks are for backup/redundancy assertion anyway)
but anyway, the main problem is: i dont want to generate a random pin that is one (or maybe two) digit(s) different from another,. i.e.
11111111 is too close to 14115111 and much too close to 11111811. 11121111 is right out of the question as it can be entered as a typo, as is 11111411 because of the numpad
so i'm after thoughts on how to perform that check, i suppose if i went with the "big string of all pins that went before" check i could perform a number of regex searches on the string. i.e.
my pin is 12345678 and i dont want ony to be one digit different so i'd check the string against .2345678 1.345678 12.45678 and so on. think i just answered my own question, anyone else got any ideas? especially for the two digit case (dont want to be performing 36 regex checks do i!)
However, what I want to do is include a request.querystring("ID"), so that IF an ID is defined, eg ID=3, , it will display the relevant (not random) information. I've tried this every way I can think and get type mismatches, etc etc. It's probably really simple but I can't see it.
<%
limit=3
redim link(limit)
redim image (limit)
link(1)="xxx"
image(1)="image1.jpg"
link(2)="xxx"
image(2)="image2.jpg"
link(3)="xxx"
image(3)="image3.jpg"
randomize
random=int(rnd*limit)+1
%>
<center>
<a href="<%= link(random) %>">
<img src="<%= image(random) %>" border="0"></a>
I just wanted to know whats the best way to generate 50 or say X amount of number at random without having to repeat any of the previous number...
so far I've the following:
[VBS]<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
function RandomNumber()
dim theRandom
Randomize
'RandomNumber = Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
theRandom= Int((99 - (0) + 1) * Rnd + (0))
if (theRandom<10) then theRandom = "0" & theRandom
RandomNumber = theRandom
end function
%>[/VBS]
and then I've this in the body of HTML doc: Code:
We have the need to have a random token (a 16 char alphanumeric field) to be used as the key for one of our SQL tables. I have created a random token generator, however after only 3 months in production, it appears that we had an instance where a token that already existed in the tables was created. There are 3810 records currently in the database so it isn't like there are billions of records there.
I contacted an old college buddy of mine who is a mathematician, and he claims, assuming that random really does mean random, that the chances of getting a duplicate token are 1 in 79.5 septillion (79,500,000,000,000,000,000,000,000).
So my conclusion is that this was either a complete freak of nature occurance, or my random generator isn't really all that random. Here is the code behind how I am generating this: Code:
I need help with some asp code that would allow me to grab the last record id and add one to it for the new record being inserted.
I am new to asp and have been banging my head up against the wall trying to get this to work. I am currently using Visual FoxPro 6 for my database.
The SQL statement I am trying to use is:
strSQL = "SELECT Max(contact_id) FROM CustomerContact;"
i'm building an ecommerce website and I want to create a unique orderID for each new order. My problem is that I don't want to have a random number but a number where each orderid is one higher then the last order like for example 4850323, 4850324, 4850325....
I tried to do this by using an application variable where 1 is added after every order but
this doesn't garantee a unique number because if IIS is reset it also resets the application variable.
I've a databse of product in which I've unique ProductCode plus a ID that increments by 1 (AutoNumber). both the code and ID are unique and there will be no duplicate but is it worth having both in the databse?
I mean, can I not just use the productCode and forget about the ID? does this makes any difference? as far as I can see I'll have no problem in using the ProductCode. how you'd do it.
I need to insert some number into database as text. My problem is if I insert the number (ie. 4.0), the value in the database only show (4). So, is it possible to convert a real number into text number using ASP?
View Replies View RelatedWhats the best way to create a Unique ID and insert it into a Access DataBase? the field that holds this is a text field, and is called company ID.
Its a text field because it seems to cause less hassle
I have a list from a database which I have made into a dropdown box, with each option as one line from the list.
At the moment I have several repeat values which I do not want.
I can set up a series of nested if statements and loops to remove the duplicate values but I would expect there to be a function which does this much more easily.My question is:
Is there an easy way of only displaying unique values from a database using ASP and SQL.
This is about a simple form validation in asp using javascript.there is one field called invoice_number which requires an unique invoice number as input. Whenever user inputs duplicate values message should pop up as warning on submit of the form. A sql fetches all the invoice nos. from database into an array using getrows.how do i use the result of getrows in javascript to perform client side validation
View Replies View RelatedI am trying to find a best algorithm to generate unque id(alphanumeric less than 10 character long - not GUID) for entering orders in orders table for an e-commerce site.
View Replies View RelatedI need to implement a email confirmation ASAP, but I need a way to create a unique ID. Can I just use the SessionID? People will click a link in their email, (if it exists), and my site will validate it. ASP.NET has GUIDs, but ASP doesn't. I'm wondering if a SessionID will just do it?
View Replies View Related