473,749 Members | 2,384 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

3 New Member
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 2088
Dormilich
8,658 Recognized Expert Moderator Expert
I see no benefit of one of the programming languages over the other, as long as your logic is correct.
Sep 21 '10 #2
jhernandy
3 New Member
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 Recognized Expert Expert
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
jhernandy
3 New Member
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
433
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
3490
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
7379
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 have utilised the following random number source code http://www.agner.org/random/ What I have found is that there is a problem with seeding. The code generates a seed based on time(0). I have found that I need to increment
70
6269
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 using the high-order bits returned by rand() instead of the low-order bits, avoiding using rand() for anything that wants decently random numbers, not using rand() if you want more than approx. UINT_MAX total different sequences, and so on. So I...
5
3351
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 double value in the range could come up with equal probability). I'd also like to be able to seed this generator (e.g., via the clock) so that the same sequence of random values don't come up every time. Anybody have an easy and fast...
9
16766
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 random result from generate button : 10016486 + 22423 = 10038909 10038909 + 22423 = 10061332 and so on, maximum to 99999985 or if somebody can convert below c++ code to working javascript/html random number generator. #include <cstdlib> #include...
16
539
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 given a seed. - Relatively uniform, does not have to be perfect. The application is not a security or statistics application, the quality of numbers is not a priority although a fairly uniform
0
8996
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9566
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9388
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9333
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8256
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.