Wednesday, 27 July 2016

Percentage Calculators Using Javascript

3-way Percent Calculators

Find the sentence that represents your problem.

Enter the values and click Calculate.


<html>
<body bgcolor="#FFFFFF" leftmargin=0 topmargin=0 >
<table width="780" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>&nbsp;&nbsp;</td>
<td valign="top">
<script language="JavaScript">
function calc1(form) {
a = form.a.value/100;
b = a*form.b.value;
form.total1.value = b;
}
function calc2(form) {
a = form.c.value;
b = form.d.value;
c = a/b;
d = c*100;
form.total2.value = d;
}
function calc3(form) {
a = form.e.value;
b = form.f.value/100;
c = a/b;
;
form.total3.value = c;
}
</script>
<table width="468" border="0" cellspacing="2" cellpadding="2">
<tr> 
<td>
<form name="form1">
<div align="left"> 
<table border=1 cellpadding=0 cellspacing=0 width="468">
<tr> 
<td align=center> 
<div align="left"><b>What is</b> 
<input type="text" name="a" size=5>
<b>% of</b> 
<input type="text" name="b" size=8>
<b>?</b></div>
</td>
<td align=center> 
<input type="button" value="Calculate" onClick="calc1(this.form)" name="button">
</td>
<td align=center>Answer: 
<input type="text" name="total1" size=8 maxlength=40>
</td>
</tr>
<tr bgcolor="#eeeecc"> 
<td align=center colspan=3>&nbsp;</td>
</tr>
<tr> 
<td align=center> 
<div align="left"> 
<input type="text" name="c" size=9>
<b>&nbsp;is what percent of</b> 
<input type="text" name="d" size=9>
<b>?</b></div>
</td>
<td align=center> 
<input type="button" value="Calculate" 
       onClick="calc2(this.form)" name="button2">
</td>
<td align=center>Answer: 
<input type="text" name="total2" size=5>% 
</td>
</tr>
<tr bgcolor="#eeeecc"> 
<td align=center colspan="3">&nbsp;</td>
</tr>
<tr> 
<td align=center> 
<div align="left"> 
<input type="text" name="e" size=10>
<b>&nbsp;is 
<input type="text" name="f" size=8>
% of</b> <b>what?</b></div>
</td>
<td align=center> 
<input type="button" value="Calculate" 
       onClick="calc3(this.form)" name="button3">
</td>
<td align=center>Answer: 
<input type="text" name="total3" size=10>
</td>
</tr>
</table>
</div>
</form>
</td>
</tr>
</table>
</body>
</html>
Percentage Calculators
  
3-way Percent Calculators

Find the sentence that represents your problem.

Enter the values and click Calculate.
What is % of ?
Answer:
 
 is what percent of ?
Answer: %
 
 is % of what?
Answer:

 

No comments:

Post a Comment