English

# Equivalent Fractions Calculator (Calc) in Javascript

Simple javascript calculator helps to calculate the equivalent fractions for the given numerators and denominators.

# Features

• Equivalent fraction defines the same part of the whole.
• It can be generated by multiplying / dividing the numerator and denominator by the same number.
• Online script which makes calculations easy and fast.
• This is a free javascript calculator.

# Preview

## Equivalent Fractions Calculation

 Enter Whole Numbers Only Numerator/Denominator: / Equivalent Fractions

Code

<!-- Script by hscripts.com -->
<!-- More scripts @www.hscripts.com -->
<html>

<title>Equivalent Fractions Calculator in Javascript </title>
<script LANGUAGE="JavaScript" >
function calc() {
var n=document.getElementById("n").value;
var num=parseInt(n);
if (isNaN(num) || num <0) {
}
var n1=document.getElementById("n1").value;
var num2=parseInt(n1);
if (isNaN(num2) || num2 <0) {
}
for (var i=1;(i <num) ||(i == num);i++) {
if (num % i == 0) {
for (var j=1;(j <num2) ||(j == num2);j++) {
if (num2 % j == 0) {if( i ==j){
var m = Math.max(i,j);
}
var z = num/m;
var f = num2/m;
var z1=z*2;
var f1=f*2;
var z2=z*3;
var f2=f*3;
var z3=z*4;
var f3=f*4;
var z4=z*5;
var f4=f*5;
var z5=z*6;
var f5=f*6;
var z6=z*7;
var f6=f*7;
var z7=z*8;
var f7=f*8;
var z8=z*9;
var f8=f*9;
var z9=z*10;
var f9=f*10;
document.getElementById("res").value =
z + "/" + f+" , "+"" +z1 + "/" + f1+" , "+""+z2 + "/" + f2+" , "+""+z3 + "/" + f3+" , "+""+z4 + "/" + f4+" , "+""+z5 + "/" + f5+" , "+""+z6 + "/" + f6+" , "+""+z7 + "/" + f7+" , "+""+z8 + "/" + f8+" , "+""+z9 + "/" + f9 ;
}
}
}
}
}
function re()
{
document.getElementById("n").value ="";
document.getElementById("n1").value = "";
document.getElementById("res").value = "";
}
function checnum(as)
{
var dd = as.value;
if(dd.lastIndexOf(" ")>=0){dd = dd.replace(" ","");as.value = dd;
}
if(isNaN(dd))
{
dd = dd.substring(0,(dd.length-1));
as.value = dd;
}
}
function chk(){
var sds = document.getElementById('dum');
if(sds == null){alert("You are using a free package.\n You are not allowed to remove the tag.\n");
document.getElementById("maindiv").style.visibility="hidden";
}
var sdss = document.getElementById("dumdiv");
if(sdss == null){alert("You are using a free package.\n You are not allowed to remove the tag.\n");}
}
</script>
<style>.frms textarea{min-height: 100px;font-family:Tahoma, Geneva, sans-serif;
line-height:18px;}textarea
{
width:99%;
height:auto;
background:#fff;
border:#ddd 1px solid;
margin-top:5px;
margin-bottom:15px;
}
h2 {border-bottom: 1px solid #ebebeb;color: #474747;font-size: 1.4em;font-weight: normal;line-height: 130%;
}
.frms
{
margin:0 auto;
font-family:Tahoma, Geneva, sans-serif;
color:#333;
font-size:.9em;
line-height:1.2em;
}
{
width:99%;
background:#fff;
border:#ddd 1px solid;
margin-top:5px;
margin-bottom:15px;
height:35px;
}
.frms input:hover,textarea:hover,select:hover
{
}
.frms input:focus,textarea:focus,select:focus
{
-webkit-box-shadow: inset 7px 4px 7px -7px rgba(0,0,0,0.42);
-moz-box-shadow: inset 7px 4px 7px -7px rgba(0,0,0,0.42);
box-shadow: inset 7px 4px 7px -7px rgba(0,0,0,0.42);
border:#9d9983 1px solid;
}
.frms input[type="submit"],input[type="reset"],input[type="button"],button,.yellow_button,.blue_button
{
font-weight:bold;
color:#fff;
cursor:pointer;
margin:10px 0;
border:none;
}
.frms input[type="submit"]
{
background:#75ab22;
border-bottom:#629826 3px solid;
}
.frms input[type="reset"]
{
background:#ee765d;
border-bottom:#d95e44 3px solid;
}
input[type="button"],button,.blue_button
{
background:#468cd2;
border-bottom:#3277bc 3px solid;
}
.frms label
{
font-size:1.2em;
}
.resp_code
{
margin:5px 10px 10px 300px;
font:normal 1em/1.3em Tahoma, Geneva, sans-serif;
color:#333;
background:#f8f8f8;
border:#ddd 1px solid;
overflow:auto;width:50%;
}
table td{font-size: 0.8em;
}
@media screen and (max-width: 480px)
{
.resp_code
{width:auto !important;margin:0px !important;
}
}
</style>
<div class='resp_code' id='maindiv' align='center'><h2>Equivalent Fractions Calculation</h2><form name=first class='frms'>
<table width=100%><tr><td colspan=4><b>Enter Whole Numbers Only </b></td></tr><tr><td>Numerator/Denominator:</td><td> <input type=text id=n size=4 onkeyup=checnum(this) maxlength=7> </td><td> / </td><td><input type=text id=n1 size=4 onkeyup=checnum(this) maxlength=7></td></tr><tr><td colspan=4 align=center><input type=button value=Calculate onClick=calc()>
<input type=reset value=Reset onclick=re()><span
</div>
</body>
</html>

• Release Date - 16-04-2015
• For customization of this script or any script development, mail to support@hscripts.com

# Usage

• Copy the above code and paste in your webpage to use the equivalent fraction calc.
• Calculate the equivalent fractions by entering the numerator and denominator value.
• To use the functionality of the script alone, copy the code inside the script tag and integrate into your webpage.