By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,530 Members | 891 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,530 IT Pros & Developers. It's quick & easy.

I need help using js auto insert....

P: 12
I'm trying to use js function to: upon entering "paidamt" change the "amtdue",
"prevbal",auto-insert the current date(datepaid), change"pd", and increment
the "checkno". I had this working at one time but memory precludes the use of the
onblur. The following code displays all values for selected record from database
and only updates "paidamt". Any help?

Expand|Select|Wrap|Line Numbers
  1. echo "<tr>
  2. <td><input type='text' readonly size=15 name='acctno' value='" . $row['acctno'] . "' ></td>
  3. <td><input type='text' readonly size=25 name='bname' value='" . $row['bname'] . "'></td>
  4. <td><input type='text' readonly size=25 name='purpose' value='" . $row['purpose'] . "'></td>
  5. <td><input type='text' size=7 id='paidamt' name='paidamt' value='" . $row['paidamt'] ."' 
  6. onBlur='calculate_paid(this)'></td>
  7. <td><input type='text' size=5 name='amtdue' value='" . $row['amtdue'] . "' ></td>
  8. <td><input type='text' size=5 name='prevbal' value='" . $row['prevbal'] . "' ></td>
  9. <td><input type='text' size=5 name='datepaid' value='" . $row['datepaid'] . "' ></td>
  10. <td><input type='text' size=5 name='pd' value='" . $row['pd'] . "' ></td>
  11. <td><input type='text' size=5 name='checkno' value='" . $row['checkno'] . "' ></td>
  12. </tr>";
Expand|Select|Wrap|Line Numbers
  1. function $_(IDS) { return document.getElementById(IDS); }
  2. function calculate_paid() 
  3.   { 
  4.    var recur = parseInt(document.getElementById("recur").value;
  5.    var pd = parseInt(document.getElementById("pd").value;   
  6.    var shipamt = parseFloat(document.getElementById("shipamt").value;
  7.    var paidamt = parseFloat(document.getElementById("paidamt").value;
  8.    var prevbal = parseFloat(document.getElementById("prevbal").value;
  9.    var amtdue = parseFloat(document.getElementById("amtdue").value;
  10.    var checkno = parseInt(document.getElementById("checkno").value;
  11.    var datepaid = parseFloat(document.getElementById("datepaid").value;
  12.    var dateNow = new Date();
  13.    var dayNow = dateNow.getDate();
  14.    var datePaid = (dateNow.getMonth()+1)+"/"+dateNow.getDate()+"/"+dateNow.getFullYear();
  15.       datepaid.value = datePaid; 
  16. prevbal.value = parseFloat(amtdue.value) + parseFloat(shipamt.value) - parseFloat(paidamt.value);
  17. amtdue.value = parseFloat(amtdue.value) + parseFloat(shipamt.value) - parseFloat(paidamt.value);
  18. checkno.value = parseInt(checkno.value) + "1";
  19.    if(recur.value=="N")
  20.       {prevbal.value= amtdue.value;} 
  21.    if(prevbal.value=="0.00")
  22.       {pd="P";} 
  23.    if(amtdue.value=="0.00")
  24.       {pd="P";}
May 14 '14 #1
Share this Question
Share on Google+
1 Reply


Dormilich
Expert Mod 5K+
P: 8,639
The following code displays all values for selected record from database
and only updates "paidamt". Any help?
of the IDs mentioned in lines #4 to #11 only paidamt exists.
lines #15 to #18 you’re using the variables as if they were input elements, but they are defined as numbers previously.
May 14 '14 #2

Post your reply

Sign in to post your reply or Sign up for a free account.