hey, hey youse peoples, I;m trying to get this code to:
upon entering the paidamt, insert the date and totpaid.
I had it working for awhile but screwed it up. The "select works. Thanks for helping.
function $_(IDS) { return document.getElementById(IDS); }
function calculate_paid() {
var dayslate = document.getElementById("dayslate");
var paidamt = document.getElementById("paidamt");
var rentdue = document.getElementById("rentdue");
var prevbal = document.getElementById("prevbal);
var shipamt = document.getElementById("shipamt");
var datepaid = document.getElementById("datepaid");
var totpaid = document.getElementById("totpaid");
var dateNow = new Date();
var dayNow = dateNow.getDate();
var datePaid = (dateNow.getMonth()+1)+"/"+dateNow.getDate()+"/"+dateNow.getFullYear();
datepaid.value = datePaid;
totpaid.value = parseInt(totpaid.value) + parseInt(paidamt.value);
datepaid.value = datePaid;
var totOwed = parseInt(rentdue.value) + parseInt(prevbal.value);
var stillOwed = totOwed - parseInt(paidamt.value);
if (totpaid.value >= totOwed)
{prevbal.value = totOwed - totpaid.value;}
if (stillOwed < prevbal.value && stillOwed > 0)
{prevbal.value = prevbal.value - stillOwed;
stillOwed = 0;}
}
if (dayslate >= 120){dayslate = 120}
<html><head>
<!--when the paidamt is keyed in, the current date,& totpaid are autoinserted-->
<script type="text/javascript" src="payment.js"></script>
<script type="text/javascript">
window.google_analytics_uacct = "UA-256751-2";
</script>
<script type="text/javascript">
window.google_analytics_uacct = "UA-256751-2";
</script>
</head><body>
<?php
// error_reporting(0);
error_reporting(E_ALL ^ E_NOTICE);
mysql_connect('localhost','root','');
mysql_select_db('oodb') or die( "Unable to select database");
if(!empty($_POST["submit"]))
{
$acctno = $_POST['acctno'];
$query="SELECT * FROM oocust Where acctno='$acctno'";
$result=mysql_query($query);
if(mysql_num_rows($result))
{
echo "<form action='#' method='post'>Invoice Payment :<br /><br />
<table cellspacing=0 cellpadding=0 border=1>
<tr>
<th>acctno</th>
<th>Name</th>
<th>Description</th>
<th>Paid</th>
<th>Due</th>
<th>Date Paid</th>
<th>comment</th>
<th>totpaid</th>
</tr>";
while($row = mysql_fetch_assoc($result))
{
echo "<tr>
<td><input type='text' size=15 value='" . $row['acctno'] . "'></td>
<td><input type='text' size=25 value='" . $row['bname'] . "'></td>
<td><input type='text' size=15 value='" . $row['descr'] . "'></td>
<td><input type='text' size=7 id='paidmamt' value='" . $row['paidamt'] . "'
onblur='calculate_paid(this)'></td>
<td><input type='text' size=7 id='rentdue' name='rentdue' value='" . $row['rentdue'] . "'></td>
<td><input type='text' size=7 id='prevbal' name='prevbal' value='" . $row['prevbal'] ."'
onBlur='calculate_paid(this)'></td>
<td><input type='text' size=10 id='datepaid' name='datepaid' value='" . $row['datepaid'] . "'></td>
<td><input type='text' size=7 id='totpaid' name='totpaid' value='" . $row['totpaid'] . "'></td> </tr>";
}
echo "</table>
<input type='submit' name='update' value='make payment' />
</form>";
}
else{echo "No listing for account# $acctno.<br />Please select another.<br />";}
}
if(!empty($_POST["update"]))
{
$sql = "UPDATE oocust SET
paidamt = '" . mysql_real_escape_string($_POST['paidamt']) . "',
rentdue = '" . mysql_real_escape_string($_POST['rentdue']) . "',
datepaid = '" . mysql_real_escape_string($_POST['datepaid']) . "',
totpaid = '" . mysql_real_escape_string($_POST['totpaid']) . "',
WHERE acctno='".$_POST["acctno"]."'";
mysql_query($sql) or die("Update query failed: " . mysql_error());
echo "Record for acct# ".$_POST["acctno"]." has been updated";
}
?>
<form method="post" action="#">
<br />
<input type="text" name="acctno"/> <p>
<input type="submit" name="submit" value="select acct#."/>
</form>
<script type="text/javascript"><!--
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
//-->
</script>
<script type="text/javascript"><!--
try {
var pageTracker = _gat._getTracker("UA-256751-2");
pageTracker._trackPageview();
} catch(err) {}
//-->
</script>
<script type="text/javascript"><!--
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
//-->
</script>
<script type="text/javascript"><!--
try {
var pageTracker = _gat._getTracker("UA-256751-2");
pageTracker._trackPageview();
} catch(err) {}
//-->
</script>
</body></html>