I am making a very simple fraction calculator however my code is not working.
<title>Fraction Calculator</title>
</head>
<body>
<center><h1>Fraction Calculator</h1></center>
<body bgcolor="yellow" />
<center>
Fraction One Num:<input id="textTop" type="text" /> Fraction Two Num<input id="textTop2" type="text" /> </br>
<title>Fraction Calculator</title>
</head>
<body>
<center><h1>Fraction Calculator</h1></center>
<body bgcolor="yellow" />
<center>
Fraction One Num:<input id="text1" type="text" /> Fraction Two Num<input id="text2" type="text" /> </br>
Fraction One Den:<input id="textBot" type="text" /> Fraction Two Den<input id="textBot2" type="text" /> </br>
EqualN:<input id="txtNum" type="text"/> </br>
EqualD:<input id="txtDen" type="text" /> </br>
<input id="btnPlus" type="button" Value="+" /> <input id="btnSubtract" type="button" value="-" /> <input id="btnDivide" type="button" value="/" /> <input id="btnTimes" type="button" value="*" /> </br>
<input id="btnSim" type="button" value="Simplify" />
</center>
</body>
</html>
<script language="vbscript">
Sub btnPlus_OnClick()
txtNum.innertext=Cint(textTop.value)*Cint(textBot2.value)+Cint(textTop2.value)*Cint(textBot.value)
txtDen.innertext=Cint(textBot.value)*Cint(textBot2.value)
end sub
Sub btnSubtract_OnClick()
txtNum.innertext=Cint(textTop.value)*Cint(textBot2.value)-Cint(textTop2.value)*Cint(textBot.value)
txtDen.innertext=Cint(textBot.Value)*Cint(textBot2.value)
end sub
Sub btnTimes_onclick()
txtNum.innertext=Cint(textTop.value)*Cint(textTop2.value)
txtDen.innertext=Cint(textBot.value)*Cint(textBot2.value)
end sub
Sub btnDivide_onclick()
txtNum.innertext=Cint(textTop.value)*Cint(textBot2.value)
TxtDen.innertext=Cint(textTop2.value)*Cint(textBot.value)
end sub
</script>
<script language="vbscript">
Sub btnSim_onclick()
Dim Com
dim numer
dim denom
numer = (txtNum.value)
denom = abs(txtDen.value)
Do
Com = numer mod denom
if Com <> 0 then
numer = denom
denom = com
else
Com = denom
end If
loop until Com <> 0
end sub
</script>
The bit that is not working is the last bit which is meant to simplify the fraction:
<script language="vbscript">
Sub btnSim_onclick()
Dim Com
dim numer
dim denom
numer = (txtNum.value)
denom = abs(txtDen.value)
Do
Com = numer mod denom
if Com <> 0 then
numer = denom
denom = com
else
Com = denom
end If
loop until Com <> 0
end sub
</script>
Please help me as I really need help.
<title>Fraction Calculator</title>
</head>
<body>
<center><h1>Fraction Calculator</h1></center>
<body bgcolor="yellow" />
<center>
Fraction One Num:<input id="textTop" type="text" /> Fraction Two Num<input id="textTop2" type="text" /> </br>
<title>Fraction Calculator</title>
</head>
<body>
<center><h1>Fraction Calculator</h1></center>
<body bgcolor="yellow" />
<center>
Fraction One Num:<input id="text1" type="text" /> Fraction Two Num<input id="text2" type="text" /> </br>
Fraction One Den:<input id="textBot" type="text" /> Fraction Two Den<input id="textBot2" type="text" /> </br>
EqualN:<input id="txtNum" type="text"/> </br>
EqualD:<input id="txtDen" type="text" /> </br>
<input id="btnPlus" type="button" Value="+" /> <input id="btnSubtract" type="button" value="-" /> <input id="btnDivide" type="button" value="/" /> <input id="btnTimes" type="button" value="*" /> </br>
<input id="btnSim" type="button" value="Simplify" />
</center>
</body>
</html>
<script language="vbscript">
Sub btnPlus_OnClick()
txtNum.innertext=Cint(textTop.value)*Cint(textBot2.value)+Cint(textTop2.value)*Cint(textBot.value)
txtDen.innertext=Cint(textBot.value)*Cint(textBot2.value)
end sub
Sub btnSubtract_OnClick()
txtNum.innertext=Cint(textTop.value)*Cint(textBot2.value)-Cint(textTop2.value)*Cint(textBot.value)
txtDen.innertext=Cint(textBot.Value)*Cint(textBot2.value)
end sub
Sub btnTimes_onclick()
txtNum.innertext=Cint(textTop.value)*Cint(textTop2.value)
txtDen.innertext=Cint(textBot.value)*Cint(textBot2.value)
end sub
Sub btnDivide_onclick()
txtNum.innertext=Cint(textTop.value)*Cint(textBot2.value)
TxtDen.innertext=Cint(textTop2.value)*Cint(textBot.value)
end sub
</script>
<script language="vbscript">
Sub btnSim_onclick()
Dim Com
dim numer
dim denom
numer = (txtNum.value)
denom = abs(txtDen.value)
Do
Com = numer mod denom
if Com <> 0 then
numer = denom
denom = com
else
Com = denom
end If
loop until Com <> 0
end sub
</script>
The bit that is not working is the last bit which is meant to simplify the fraction:
<script language="vbscript">
Sub btnSim_onclick()
Dim Com
dim numer
dim denom
numer = (txtNum.value)
denom = abs(txtDen.value)
Do
Com = numer mod denom
if Com <> 0 then
numer = denom
denom = com
else
Com = denom
end If
loop until Com <> 0
end sub
</script>
Please help me as I really need help.