Wrox Programmer Forums
|
BOOK: Beginning JavaScript 2nd Edition For questions about Beginning Javascript 2nd Edition by Paul Wilton. (ISBN: 0-7645-5587-1). Published April 2004. For Javascript questions not specific to this book, please see the Javascript forum. If you have the 1st edition, please continue to use that forum instead at: http://p2p.wrox.com/forum.asp?FORUM_ID=21
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning JavaScript 2nd Edition section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 15th, 2006, 05:58 PM
Registered User
 
Join Date: Jun 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Adding calculated text fields

This is my first attempt at a web form and everything works until the final function, which returns a ReferenceError of:

E = (document.getElementById("Distribution5"), A + B + C + D, System.ReferenceError('Reference required on left side of assignment operator'));

This is the code I'm trying to use:

<script>
function cal1(){
var Units = document.getElementById('Units').value;
var Payout = document.getElementById('Payout').value;
document.getElementById('Distribution').value =Units*Payout;
}
</script>

<script>
function cal2(){
var Units2 = document.getElementById('Units2').value;
var Payout2 = document.getElementById('Payout2').value;
document.getElementById('Distribution2').value =Units2*Payout2;
}
</script>

<script>
function cal3(){
var Units3 = document.getElementById('Units3').value;
var Payout3 = document.getElementById('Payout3').value;
document.getElementById('Distribution3').value =Units3*Payout3;
}
</script>

<script>
function cal4(){
var Units4 = document.getElementById('Units4').value;
var Payout4 = document.getElementById('Payout4').value;
document.getElementById('Distribution4').value =Units4*Payout4;
}
</script>

<script>
function cal5() {
A = document.getElementById('Distribution');
B = document.getElementById('Distribution2');
C = document.getElementById('Distribution3');
D = document.getElementById('Distribution4');
E = (A + B + C + D)
E = document.getElementById('Distribution5')= A+B+C+D;
}
</script>

I am sure this is very elementary but any help would be very much appreciated!

TIA


Mfero
University of Washington
Treasury Office
 
Old June 19th, 2006, 04:07 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii Mfero!!
your cal5 funcation should be like this
<script>
 function cal5() {
A = document.getElementById('Distribution').value;
B = document.getElementById('Distribution2').value;
C = document.getElementById('Distribution3').value;
D = document.getElementById('Distribution4').value;
E = (A + B + C + D)
//E = document.getElementById('Distribution5')= A+B+C+D;
document.getElementById('Distribution5').value=E
}
</script>

Make sure that document.getElementById('Distribution') to document.getElementById('Distribution4') has some values
since document.getElementById('Distribution4') returns object,not the actual value ,in order to add those elements you need
document.getElementById('Distribution4').value.

Hope this will help you


Cheers :)

vinod
 
Old February 10th, 2007, 10:14 AM
Authorized User
 
Join Date: May 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Your missing the semi-colon at the end of the line , E = (A + B + C + D)

---
Lie to yourself
and get everyone to agree





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create calculated fields MacDevv C# 3 August 16th, 2006 09:38 AM
Help with summing calculated fields on a report dbartelt Access 6 January 4th, 2006 03:33 PM
Adding Fields to a Text Box Question ausmoran BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 1 December 1st, 2005 06:15 PM
Storing Calculated Fields dearnne Access 3 September 2nd, 2004 05:30 PM
Storing Calculated Fields dearnne Access VBA 1 August 30th, 2004 10:54 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.