Hi,
I am new to programming and PHP and need some help converting this client side page to a server side PHP page. Here's what I have to convert:
Script to be executed
I am new to programming and PHP and need some help converting this client side page to a server side PHP page. Here's what I have to convert:
Script to be executed
Code:
document.write ("<table ><table class=ctable width=50% border='0'>");
document.write ("<tr>","<td>");
document.write ("<form name=first>");
document.write ("<table class=ctable>");
document.write ("<tr>","<td>Loan Amount:</td>","<td><input name=aa type=text size=15
onkeyup=checnum(this) ></td>","</tr>");
document.write ("<tr>","<td>Interest Rates:</td>","<td><input name=bb type=text size=15
onkeyup=checnum(this) ></td>","</tr>");
document.write ("<tr>","<td>Term(Years):</td><td><input name=cc type=text size=15
onkeyup=checnum(this)></td>","</tr>");
document.write ("</table>");
document.write ("<br>");
document.write ("<input type=button name=ss value=calculate onclick=loan() class=calc>");
document.write ("<br>");
function checnum(as)
{
var dd = as.value;
if(isNaN(dd))
{
dd = dd.substring(0,(dd.length-1));
as.value = dd;
}
}
function loan()
{
var a = document.first.aa.value;
var b = document.first.bb.value;
var c = document.first.cc.value;
var n = c * 12;
var r = b/(12*100);
var p = (a * r *Math.pow((1+r),n))/(Math.pow((1+r),n)-1);
var prin = Math.round(p*100)/100;
document.first.r1.value = prin;
var mon = Math.round(((n * prin) - a)*100)/100;
document.first.r2.value = mon;
var tot = Math.round((mon/n)*100)/100;
document.first.r3.value = tot;
for(var i=0;i<n;i++)
{
var z = a * r * 1;
var q = Math.round(z*100)/100;
var t = p - z;
var w = Math.round(t*100)/100;
var e = a-t;
var l = Math.round(e*100)/100;
a=e;
}
}
document.write ("<br>");
document.write ("<table class=ctable border=1 cellspacing=0 cellpadding=3>");
document.write ("<tr>","<th>Payment</th>","<th>Total Interest Paid</th>","<th>Monthly
Interest</th>","</tr>");
document.write ("<tr>","<td> <input name=r1 type=text readonly > </td>","<td> <input
name=r2 type=text readonly ></td>","<td> <input name=r3 type=text readonly > </td>","</tr>");
document.write ("</td>","</tr>");
document.write ("</table>","</form>");
document.write ("</table>");
[B]Main PHP Page[/B]
<?php echo '<?xml version="1.0" encoding="IUTF-8"?>'; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="HTML Tidy for Linux (vers 25 March 2009), see www.w3.org" />
<title></title>
<body>
<script src="table.js" type="text/javascript">
</script>
</body>
</html>
Comment