Hi guys, my programming is a pasttime but still important to me. The following
code is a payment doc. allowing partial payments. Balances are put in “prevbal”
field. Complete payments get a “P” code. When the paidamt is keyed in, the
current date is autoinserted. If a recurring debt the amtdue stays the same.
If it is, the amtdue is calculated. I’m unsure if the failure is in the
javascript or not? The code using the JS follows: The display is right, manual update
works but not correctly, I get no error & I fear the JS is incorrect but maybe the php
onblur statement. I’ve worked on this for a long time. I’m not asking for code, pointers maybe?
==============================================================================
:
function $_(IDS) { return document.getElementById(IDS); } function calculate_paid() { var status = document.getElementById(“status”); var pd = document.getElementById(“pd”); var payec = document.getElementById(“payec”); var paidamt = document.getElementById(“paidamt”); var amtdue = document.getElementById(“amtdue”); var prevbal = document.getElementById(“prevbal”); var shipamt = document.getElementById(“shipamt”); var datepaid = document.getElementById(“datepaid”); var dateNow = new Date(); var dayNow = dateNow.getDate(); var datePaid = (dateNow.getMonth()+1)+”-“+dateNow.getDate()+”-“+dateNow.getFullYear(); datepaid.value = datePaid; var owed.value == parseFloat(amtdue.value) + parseFloat(shipamt.value) + parseFloat(prevbal.value) – parseFloat(paidamt.value); if(status==”N”){amtdue.value = owed.value;} if(owed==”0.00″) { pd.value = “P”; shipamt=”0.00″, prevbal=”0.00″;} }
========================================================================
[PHP]
“;}
echo “
“;
}
else{echo “invalid entry
Select another?
“;}
}
if(!empty($_POST[“update”]))
{
$sql = “UPDATE oocust SET
amtdue = ‘” . mysql_real_escape_string($_POST[‘amtdue’]) . “‘,
paidamt = ‘” . mysql_real_escape_string($_POST[‘paidamt’]) . “‘,
datepaid = ‘” . mysql_real_escape_string($_POST[‘datepaid’]) . “‘,
pd = ‘” . mysql_real_escape_string($_POST[‘pd’]) . “‘
WHERE acctno='”.$_POST[‘acctno’].”‘”;
mysql_query($sql) or die(mysql_error());
echo “Success!”;
}
?>
[/PHP][HTML]]
[/HTML]