473,387 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

I need help using js auto insert....

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
1 1388
Dormilich
8,658 Expert Mod 8TB
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

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

Similar topics

1
by: Ryan Hubbard | last post by:
I'm inserting a record into MySQL 4.0 using Visual Basic ADO. When using the AddNew and Update method I am unable to retrieve the value of a Auto incrment field (Yes I know I can MoveLast but this...
9
by: Dwalker | last post by:
I just want to enter today's date in a text input box with the format mm/dd/yyyy when it receives focus. I've been playing around with this but just can't seem to get it to work. Any help would...
0
by: joeboatertx | last post by:
I have some simple C++ code I am trying to compile using VS.NET 2003. (Below) Every time I try to compile I get numerous C2784 errors. If I simply comment out both of the chores.insert() lines,...
2
by: VB Programmer | last post by:
I have a table called 'MyUsers'. Some fields are as follows: UserId (p key to tie it to aspnet_Users), MyAddress, MyCity, MyState, etc... After I do a Membership.CreateUser to add the new member...
1
by: Dave | last post by:
I have a table with 3 fields of which the primary key is a autonumber. I have created my dataadapter, dataset and datagridview using a wizard. However, in the datagrid, the update and delete...
3
by: kiask2343 | last post by:
Ok I need a little help here. I need the code to insert todays date into a specific field. This is what I think I need but I don't know how to make it work. INSERT INTO target ])] VALUES...
1
by: kunal0101 | last post by:
Hi, I am a new user to access and am building a database to capture the rotation dates for employees. There is a table called "Rotation schedule" which contains "name", "Duration (in weeks) and...
0
by: tezza98 | last post by:
HI i am using BULK INSERT to copy data from a text file into a table that already exists BULK INSERT dbo.TRANStemp FROM 'D:\MSSQL\Data\TRANS.csv' WHERE dbo.TRANStemp.DateTime <> ...
12
by: badvoc | last post by:
Hi, I have had some good fortune on this site so I am back and I must iterate I am a beginer. I am having some problems getting to grips with the right technique to manage variables and...
0
by: venkyb77 | last post by:
Hi all, Can any body help me to give an approach for the given scenario. I have some form/jsp pages with so many controls in java/j2ee web application which was used struts, AJAX JASP and Spring....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.