PDA

View Full Version : Need to edit this code!


nutz00
10-22-2002, 10:28 PM
here is the code
<%
Randomize
Random_Number_Min = 1
Random_Number_Max = 1000
Random_Number = Int(((Random_Number_Max-Random_Number_Min+1) * Rnd) + Random_Number_Min)
Response.Write "Random Number = " & Random_Number & "<br>"
%>


and i want something above that you have to click a button that sais Get Member ID and when i click that it gives me the random number which is that code thats all i need i cant do that

thanks

whammy
10-23-2002, 12:02 AM
If you're using it as a Member ID, then you probably don't want to randomize a number as theoretically you can end up with a duplicate random number eventually.

If you're using a database (which I assume if you have members), I'd use an autoincrement field for the member ID. You can always add random stuff onto that if you want to make it look "l33t" and parse it out somehow...

If you're not familiar with databases and datatypes, check out the webmonkey tutorials for starters:

http://www.webmonkey.com/authoring

:)

nutz00
10-23-2002, 12:27 AM
thanks yea this is what i was planning. when a member registers they get a random number generated for that ussername, then i go to this page that picks the random number and then i make my own number and post it in my forum and the person who ever matches that number wins, its like a contest! but the thing is as you said is that when they register some might get the same number and it wont work there will be 2 winners then heehhe.

any more help would be nice!

whammy
10-23-2002, 12:30 AM
Definitely visit the above page that I provided a link for and check out the "rugged ASP" tutorial - that will give you a LOT more help than I (or anyone else here) can give you without you learning the basics - if you just try the stuff on your own without taking tutorials (google is a good resource for ASP tutorials too), then you will be like a man in a locked room in the dark trying to escape by picking the lock with a broken hairpin, but the hairpin is somewhere on the floor of the room...

Not to mention you'll probably frustrate everyone else with basic questions that would be answered by almost any tutorial. ;)

If you have a Windows System and Notepad, then you have the ability to do everything in that tutorial. You may have to install IIS or PWS, and if you run into any problems with that I'm sure everyone here will be glad to help. :D

A few other good sites for learning ASP and getting good scripts:

http://www.liquidrage.com
http://www.aspalliance.com
http://www.haneng.com
http://www.devguru.com

and last, but not least:

http://www.w3schools.com/asp

although that site will assume you already know a few basics usually...

I really tend to hesitate in answering database type questions if you aren't familiar with at least the basics of ASP and databases on your own, since it usually just leads to a mess of confusion for all parties involved (and the answers people may give you can be even MORE confusing if you haven't learned the basics, since people will generally assume a certain degree of understanding when answering your questions).

But don't let my post scare you - I'm trying to get you started on the right path so you know enough to figure this stuff out on your own - however I'm sure plenty of people including me will be glad to help you along that path.

Server-side languages and databases aren't rocket science... you can master them just as easily as anyone else here with a few tutorials. :)

raf
10-23-2002, 08:54 AM
A part from learning to code and manage a db, analyzing and planning are equelly important and are great problemsolving tools.

in fact, you don't need to assign a random number to the users. you only need to do a random selection of one of the users (based on the autoincremented Member ID-variable or on whatever variable).

Again : "there is no sollution because their is no problem"

whammy
10-24-2002, 12:47 AM
Yup... for instance, if I wanted to randomly give one of my website members a prize, I'd just loop through my database and assign each member's autoincremented "id" to an array.

Then I'd use a random number limited by that array's upper bound, and choose the winner like that.

Fairly simple. :D