473,387 Members | 1,483 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,387 software developers and data experts.

Random number generator on HTML program - only select 5 out of1-100 and no dupilcates

I have built a Table using HTML and would like to have a random number genereator, genereate numbers in each of the 5 boxes on the table with no duplicates between 1-50, I have a problem getting the numbers in each box on table, and creating no duplicate numbers - 3x5 square box

Expand|Select|Wrap|Line Numbers
  1. <table width="199" height="290" border="1">
  2. <tr>
  3.       <td height="45"><div align="center">
  4.         <h2><strong>T</strong></h2>
  5.       </div></td>
  6.       <td>&nbsp;</td>
  7.       <td><div align="center"><a title= " prize 1">1</a></div></td>
  8.       </tr>
  9.     <tr>
  10.       <td height="47"><div align="center">
  11.         <h2><strong>A</strong></h2>
  12.       </div></td>
  13.       <td>&nbsp;</td>
  14.       <td><div align="center"><atitle="prize 2">2</a></div>
  15.       <div align="center"></div></td>
  16.       </tr>
  17.     <tr>
  18.       <td height="53"><div align="center">
  19.         <h2><strong>B</strong></h2>
  20.       </div></td>
  21.       <td>&nbsp;</td>
  22.       <td><div align="center"><a title="prize 3">3</a></div></td>
  23.       </tr>
  24.     <tr>
  25.       <td height="47"><div align="center">
  26. <h2><strong>L</strong></h2>
  27. </div></td>
  28.       <td>&nbsp;</td>
  29.       <td><div align="center"><a title="prize 4">4</a></div></td>
  30.       </tr>
  31.     <tr>
  32.       <td height="53"><div align="center">
  33.         <h2><strong>E</strong></h2>
  34.       </div></td>
  35.       <td>&nbsp;</td>
  36.       <td><div align="center"><a title="prize 5">5</a></div></td>
  37.       </tr>
  38. </table>
  39. <h3><strong>If your number appears in the square you win prizes 1-5</strong><br />
  40.   </h3>
I thought PHP would better, is C++ or Java better??
Sep 21 '10 #1
4 2070
Dormilich
8,658 Expert Mod 8TB
I see no benefit of one of the programming languages over the other, as long as your logic is correct.
Sep 21 '10 #2
I understand that much, i just am not sure how to write the code to randomly select the numbers, and place them in the select boxes on the table and not duplicate the numbers if and when it could happen. I will also need a button to start the random number selection.
Sep 21 '10 #3
Atli
5,058 Expert 4TB
Well, if this is to be a web-page, PHP would probably be easiest to get started with. C++ is more of a desktop language, and Java is kind of... heavy.

Take a look at PHP's mt_rand function, and familiarize yourself with the while loop. If you don't want to get duplicate numbers from the random number generator (which kind of makes it... not random), then you will have to use a loop to select a new number over and over until you have a number that has not been selected before.
Sep 22 '10 #4
loop would probably work best, what I might end up doing is using numbers 1-5 and and the numbers will randomly be assigned with no duplicates. I guess random is used loosely, since I don't want the numbers to be duplicated. Any other ideas will be appreciated.
Sep 22 '10 #5

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

Similar topics

22
by: Alan Lee | last post by:
Is there any way to set RAND_MAX in rand()? I am looking for a way to get a random number between 1 and 1E9. So far I can't figure out how to do that. any suggestions would be greatly appreciated.
5
by: Pat | last post by:
I am looking for a good random number generator (such as Uniform, Normal distributions). It is better if RNG is written in C++. Thanks.
3
by: Joe | last post by:
Hi, I have been working on some code that requires a high use of random numbers within. Mostly I either have to either: 1) flip a coin i.e. 0 or 1, or 2) generate a double between 0 and 1. I...
70
by: Ben Pfaff | last post by:
One issue that comes up fairly often around here is the poor quality of the pseudo-random number generators supplied with many C implementations. As a result, we have to recommend things like...
5
by: Peteroid | last post by:
I know how to use rand() to generate random POSITIVE-INTEGER numbers. But, I'd like to generate a random DOUBLE number in the range of 0.0 to 1.0 with resolution of a double (i.e., every possible...
9
by: L33VaNcL33F | last post by:
I like to make a javascript that generate random number from the range number within : (10016486 and 99999985). the number always + 22423 that begin from 10016486 and end at 99999985 Example...
16
by: jason.cipriani | last post by:
I am looking for a random number generator implementation with the following requirements: - Thread-safe, re-entrant. - Produces consistently reproducible sequences of psuedo-random numbers...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.