Write a JavaScript code for find simple interest.

Write a JavaScript code for finding simple interest.



<html>
<head>
<script language="javascript">
function si()
{
var i,p,r,t;
p=f1.t1.value;
r=f1.t2.value;
t=f1.t3.value;
i=(p*r*t)/100;
f1.t4.value=i;
if(p=="")
{
alert("Please fill principal amt.");
}
if(r=="")
{
alert("please fill rate");
}
if(t=="")
{
alert("Please fill time");
}
}
function cl()
{
f1.t1.value="";
f1.t2.value="";
f1.t3.value="";
f1.t4.value="";
}
</script>
</head>
<body bgcolor="pink">
<form name="f1">
<table><tr>
<Td>
Principal Amt
<input type="number" name="t1"></input><br></td>
<Td>
Simple Int.
<input type="number" name="t4"readonly ></input><br></td>
</Tr>
<Tr>
<Td>
Rate &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<input type="number" name="t2"></input><br></td>
<Td align="center">
<input type="button" value="   calculate   "  name="b1"onclick="si()"></input></td>
</Tr>
<Tr>
<Td>
Time  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &nbsp; &nbsp; &nbsp;
<input type="number" name="t3" placeholder="please enter time in months"> </input><br></td>
<Td align="center">
<input type="button" value=" clear " name="b2" onclick="cl()"></input></td>
</Tr></body>
</table>
</form>
<html>
Output window..... Like as




Follow for more more notifications.....

No comments:

Post a Comment