JavaScript Scripts





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
Free Java Script Codes
Javascript List All
Slide Show Slide Show
Ad Display Ad Display
Image Effect Image Effect
Animated Image Effects Animated Image Effects
Form Validation Form Validation
Color Picker Tool Color Picker Tool
Formatting Forms Formatting Forms
Select All Select All
Dynamic Form Select Dynamic Form select
Dynamic Color Dynamic Color
Calendar Script Calendar
Textbox Counter Textbox Counter
Alphanumeric Alphanumeric
Date Time Script Date & Time
Stop Watch Script Stop Watch script
Delete Repeated Values Delete Repeated Values
Pagination Pagination
Random Generator Random Generator
Animated Text Animated Text
Cursor Position Cursor Position
User Info Window / User Info
Security Security / Authenticate
Bookmark Bookmark
Mouse Effects Mouse Effects
Title Bar Title Bar
Status Bar Status Bar
Country List Country List
Free Games Free Games
Calculators Calculators
 




Create Random Number Between Values


About
How can we create random numbers between two values, e.g: 5 and 15?
or
Creating a random number value in javascript?


Features
a)A java-script method or function will create random numbers between any two values.
b)This method takes two integer arguments. The second integer should be greater than first integer.
c)Just copy the code in to your page and use it for creating or generating random number between two different numbers.

Preview
Random Number Testing :
Enter the numbers between which a random number is to be created.


Test Result :


Code
<!--        Script by hscripts.com          -->
<!--        copyright of HIOX INDIA         -->
<!-- more scripts @ http://www.hscripts.com -->
<script type="text/javascript">
function randomnumber(num1, num2)
{
	num1 = parseInt(num1);
	num2 = parseInt(num2);
	if(num1 >= num2)
	{
		alert("Number 2 should be greater than Number 1");
	}
	else
	{
		var generator = Math.random()*(num2-num1);
		generator = Math.round(num1+generator);
		document.test.result.value = generator;
	}
}
</script>
<!-- Script by hscripts.com -->

Release Date - 16-08-2005
Get free version without ©copyright link for just 5 price

For customization of this script or any script development, contact us at support@hscripts.com


Usage
Here we have explained with a form.
a) Just copy the JavaScript code and use the method or function as random number generator.
b)Creating the form using following HTML code
    <form name="test">
    <input name=one type=text size=3>
    <input name=two type=text size=3>
    <input type=button value=test onclick="randomnumber(one.value,two.value)">
    Test Result : <input name=result readonly type=text size=6>
    </form>
c)The javascript function randomnumber() is triggered on submission of the form.



License
- The javascript (misspelled as java script) is given under GPL License
- i.e. Free use for those who use the codes as it is.
- Free, if your modification does not remove our copyright information and links.
- Click Here for detailed license information.
- You can purchase the script if your requirements does not meet our GPL License terms.
Other Links

web hosting