PDA

View Full Version : Need Rounding Help in javascript pleaseee



tarun
03-16-2007, 02:13 PM
Hey everyone,,
i Have a question,,,i am making a javascript code that would like give ur interest and stuff into an output box,,when u give them the rate, time and principle amount in 3 input boxes,,,i got it working too. and then i thought of like converting them into other currencies using buttons and i got that working too but the question,,is how do i round the output numbers to the nearest whole number? here is the code i have so far

<html>
<head>
<title> Interest </title>

<script>

var dollar
dollar = " $"

var gb
gb = " "

var gbper
gbper = " per month"

var mexi
mexi = " MXN"

var mexiper
mexiper = " MXN per month"

var euro
euro = " "

var europer
europer = " per month"

var per
per = " $ per month"

function us (form)
{
a=eval (form.amount.value)
b=eval (form.rate.value)
f=(b/100)
c=eval (form.time.value)
d=a*f*c
form.interest.value=d+dollar
tot=(d+a)
form.tot.value=tot+dollar
i=(12*c)
z=tot/i
form.permonth.value=z+per
}

function ita (converter)
{
a=eval (form.amount.value)
b=eval (form.rate.value)
f=(b/100)
c=eval (form.time.value)
d=a*f*c*0.761092929
form.interest.value=d+euro
tot=(d+a)
form.tot.value=tot+euro
i=(12*c)
z=tot/i
form.permonth.value=z+europer
}

function mex (converter)
{
a=eval (form.amount.value)
b=eval (form.rate.value)
f=(b/100)
c=eval (form.time.value)
d=a*f*c*11.1517
form.interest.value=d+mexi
tot=(d+a)
form.tot.value=tot+mexi
i=(12*c)
z=tot/i
form.permonth.value=z+mexiper
}

function gre (converter)
{
a=eval (form.amount.value)
b=eval (form.rate.value)
f=(b/100)
c=eval (form.time.value)
d=a*f*c*0.517812759
form.interest.value=d+gb
tot=(d+a)
form.tot.value=tot+gb
i=(12*c)
z=tot/i
form.permonth.value=z+gbper
}


</script>

</head>

<body background="http://www.naznet.com/community/attachment.php?attachmentid=2949&d=1143152018" vlink=aqua>

<form name="form">

<center>
<table width=100%>
<tr>
<td> <center> <font color="black" size=6 face="Comic Sans Ms">FIND YOUR INTEREST <hr width=50%> </font> </center> <p> <br> </td>
</tr>
<tr>
<td>
<center>
<table>
<tr>
<td> <input type=text value="Amount" size=5 name=amount style="color: lime; background-color: transparent; border=0px;" style="text-align:center"> </td>
<td> <input type=text value="Rate" size=2 name=rate style="color: lime; background-color: transparent; border=0px;" style="text-align:center"> </td>
<td> <input type=text value="Time" size=2 name=time style="color: lime; background-color: transparent; border=0px;" style="text-align:center"> </td>
</tr>
</table>
</center>
</td>
</tr>
<table>
</table>

</table>

<table>
<tr>
<td>
<table>
<tr>
<td> <center> Interest </center> </td>
</tr>
<tr>
<td> <center> <input type=text value="Interest" size=5 name=interest style="color: lime; background-color: transparent; border=0px;" style="text-align:center"> </center> </td>
</tr>
</table>
</td>
<td>
<table>
<tr>
<td> <center> Total Amount </center> </td>
</tr>
<tr>
<td> <center> <input type=text value="Total Amount" size=10 name=tot style="color: lime; background-color: transparent; border=0px;" style="text-align:center"> </center> </td>
</tr>
</table>
</td>
<td>
<table>
<tr>
<td> <center> Total Amount per month </center> </td>
</tr>
<tr>
<td> <center> <input type=text value="Total Amount to pay per month" size=28 name=permonth style="color: lime; background-color: transparent; border=0px;"> </center> </td>
</tr>
</table>
</td>

</tr>
</table>
</center.
<br>

<form name="converter">
<table>
<tr>
<td> <input type=button value="Italian" onMouseover="ita(this.form)" style="color: black; background-color: transparent; border=0px;" style="text-align:center"> </td>
<td> <input type=button value="Mexican" onMouseover="mex(this.form)" style="color: black; background-color: transparent; border=0px;" style="text-align:center"> </td>
<td> <input type=button value="Great Britain" onMouseover="gre(this.form)" style="color: black; background-color: transparent; border=0px;" style="text-align:center"> </td>
<td> <input type=button value="USA" onMouseover="us(this.form)" style="color: black; background-color: transparent; border=0px;" style="text-align:center"> </td>
</tr>
<table>
<tr>
<td> <center> <input type=reset value="Reset" style="color: black; background-color: orange"> </center> </td>
</tr>
</table>
</table>
</form>


</form>
<br>
<br>


<center> <a href="findtheweight.html"> Click here to find your weight on other planets </a> </center> <br>
<center> <a href="f_c_converter.html"> Click here for temperature converter </center> </a>

</body>


<style type="text/css"><STYLE TYPE="text/css">p {align=justify}
BODY{cursor: url(http://files.poqbum.com/Files/Cursors/page1/mouse.ani);}
a {cursor: url(http://files.poqbum.com/Files/Cursors/page1/mouse.ani);}
</style>

</html>

waiting for replyesss
ty