Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6242241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:55:06+00:00 2026-05-24T11:55:06+00:00

I am trying to write a simple random number generator, where you input 3

  • 0

I am trying to write a simple random number generator, where you input 3 integers into forms. The program then returns a certain amount of random numbers between the other two values. When I open the page the forms are displayed but when I click the button to generate the random numbers nothing happens. Why is this happening?

<html>
<head>
<script LANGUAGE="JavaScript">


    function randomFromTo(from, to)
    {
        return Math.floor(Math.random() * ((to - from) + 1) + from);
    }
function include(arr, obj)
{
    for(var j = 0; j < arr.length; j++)
    {
    if (arr[j] == obj) return true;
    }
}
    function RandomGen(form)
    {
    var enteries = new Array();
    var number = form.from.value;
    var top = form.top.value;
    var size = form.inputBox.value;
    var count;
    for (count = 0; count < size; count++)
    {
        var num = randomFromTo(number, top);
        if (include(enteries, num) == true)
        {
            count--;
        }
        else
        {
            enteries[count] = num;
        }
    }
    var i;
    for(i = 0; i <= enteries.length; i++)
    {
        document.write(enteries[i]);
        document.write("<br>");
    }
}


</script>
</head>

<body>

<center><h1>Random Number Generator</h1></center>
<form name="myform" action="" method="GET">Enter the Range of Values
<input type="text" name = "from" value="">to
<input type="text" name = "top" value="">
<p>Enter The Amount of Random Numbers Needed
<input type="text" name = "inputBox" value=""><p>
<input type="button" name="button" value="Generate" onClick=RandomGen(this.form)">
</form>
</body>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T11:55:07+00:00Added an answer on May 24, 2026 at 11:55 am

    You have a syntax error here

    <input type="button" name="button" value="Generate" onClick=RandomGen(this.form)">
    

    should be

    <input type="button" name="button" value="Generate" onClick="RandomGen(this.form)">
    

    Also this part should be updated, not because it will cause an error but because it is 2011

    <script LANGUAGE="JavaScript">
    

    should be

    <script type="text/javascript">
    

    Update

    Or:

    <script>
    

    no need for the type attribute because it is 2018!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write simple program using ONLY for loop ( if then
I'm trying to write a simple program in VC++ which will just initialize the
I am trying to write a simple program to open a socket channel to
I'm trying to write a very simple number guessing game (code is below). After
I'm trying to write a simple high-low program that will output like this: $
I'm trying to write a very simple shader that adds random sparkle to applicable
I'm trying to write a simple program to play music files with Pygame. My
i'm trying to write simple tcp\ip client-server. here is server code: internal class Program
I am trying to write simple Visual Studio Add-In for code generation. In my
I'm trying to write simple proxy server for some purpose. In it I use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.