JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 19th, 2014, 10:03 PM
12Strings 12Strings is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2014
Posts: 5 12Strings User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 35 m 32 sec
Reputation Power: 0
Other - Is this JS problem

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 javascript follows:
Code:
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]
<td><input type='text' readonly size=15 name='acctno' value='" . $row['acctno'] . "' ></td>
<td><input type='text' readonly size=25 name='bname' value='" . $row['bname'] . "'></td>
<td><input type='text' readonly size=25 name='purpose' value='" . $row['purpose'] . "'></td>
<td><input type='text' size=7 id='paidamt' name='paidamt' value='" . $row['paidamt'] ."'
onblur='calculate_paid(this)'></td>
<td><input type='text' size=7 id='amtdue' name='amtdue' value='" . $row['amtdue'] . "' ></td>
<td><input type='text' size=7 id='prevbal' name='amtdue' value='" . $row['prevbal'] . "' ></td>
<td><input type='text' size=10 id='datepaid' name='datepaid' value='" . $row['datepaid'] . "' ></td>
<td><input type='text' size=3 id='pd' name='pd' value='" . $row['pd'] . "' ></td><br />
<td><input type='submit' name='update' value='Make Payment' />
</tr>";
}
echo "</table>
<input type='submit' name='update' value='Update Record' />
</form>";
}
else{echo "invalid entry<br />Select another?<br />";}
}
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
Code:
]<form method="post" action="#"><br /> 
 <input type="text" name="acctno"/> <p> 
<input type="submit" name="submit" value="Select"/>
</form></body></html>

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Other - Is this JS problem


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap