473,385 Members | 1,863 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,385 software developers and data experts.

Linking To Form.

1
Hi there, Im a little stuck here, my problem is im making a house insurance form where you enter data into the feilds and the calculations link back to create the end result amount i cant seem to get the right values in the form i have all the variables correct but just linking the two is where i need a little help where have i gone wrong? and what do i need to change in order to make it work.

Here is my code so far:

Expand|Select|Wrap|Line Numbers
  1. <script language="javascript" type="text/javascript">
  2. function houseInsurance( ){
  3. var basePay = (a*0.0015)+(b*0.012)
  4. var x = (basePay*1.15)
  5. var y = (basePay*1.05)
  6. var  totalPremiums = (x+y)*1.10
  7. var result = c*totalPremiums
  8. return result;
  9. }
  10. function calculate( ) {
  11. var a = parseInt (document.form.housevalue.value)
  12. var b = parseInt (document.form.contentsvalue.value)
  13. var c = parseInt (document.form.noclaimbonus.value)
  14. document.form.total.value = result
  15. }
  16. </script>
  17.  
  18. <body>
  19. <form name = "houseInsurance"><h1>House Inurance:</h1>
  20. House Value<br>
  21. <input type = "Text" value = "Enter Amount" name = "1">
  22. <br>
  23. Contents Value<br>
  24. <input type = "Text" value = "Enter Amount" name = "2">
  25. <br>
  26. No Claim Bonus<br>
  27. <input type = "Text" value = "Enter Amount" name = "3">
  28. <br>
  29. <input type = "button" value = "result" Name = "click"
  30. onClick = "calculate()">
  31. <br>
  32. Total<br>
  33. <input type = "Text" value = "Total" name = "4">
  34. </body>
  35.  
I hope you guys are so kind enough to help me out with this one

Cheers
Apr 2 '08 #1
1 1142
pronerd
392 Expert 256MB
i cant seem to get the right values in the form
What specificly is not right? Getting the wrong number, not getting a number at all, getting an error message?



just linking the two is where i need a little help
Linking what two to what?


Here is my code so far:

Expand|Select|Wrap|Line Numbers
  1. <script language="javascript" type="text/javascript">
  2. function houseInsurance( ){
  3. var basePay = (a*0.0015)+(b*0.012)
  4. var x = (basePay*1.15)
  5. var y = (basePay*1.05)
  6. var  totalPremiums = (x+y)*1.10
  7. var result = c*totalPremiums
  8. return result;
  9. }
  10. function calculate( ) {
  11. var a = parseInt (document.form.housevalue.value)
  12. var b = parseInt (document.form.contentsvalue.value)
  13. var c = parseInt (document.form.noclaimbonus.value)
  14. document.form.total.value = result
  15. }
  16. </script>
  17.  
  18. <body>
  19. <form name = "houseInsurance"><h1>House Inurance:</h1>
  20. House Value<br>
  21. <input type = "Text" value = "Enter Amount" name = "1">
  22. <br>
  23. Contents Value<br>
  24. <input type = "Text" value = "Enter Amount" name = "2">
  25. <br>
  26. No Claim Bonus<br>
  27. <input type = "Text" value = "Enter Amount" name = "3">
  28. <br>
  29. <input type = "button" value = "result" Name = "click"
  30. onClick = "calculate()">
  31. <br>
  32. Total<br>
  33. <input type = "Text" value = "Total" name = "4">
  34. </body>
  35.  

I am assuming there must be some missing code here.

1. Almost none of the JavaScript lines are terminated with semi-colons.

2. I do not see where the houseInsurance() function is ever acutally called. Is there code that was left out.

3. The houseInsurance() function is accessing variables named a,b,x, and y that do not seem to be declared anywhere.

4. The calculate( ) function accesses a variable named result that does not seem to be declared.

5. The calculate( ) function seems to be trying to access input fields with IDs housevalue, contentsvalue, and noclaimbonus. There are no fields in the HTML with those IDs.
Apr 2 '08 #2

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

Similar topics

7
by: Steven T. Hatton | last post by:
Is there anything that gives a good description of how source code is converted into a translation unit, then object code, and then linked. I'm particularly interested in understanding why putting...
2
by: sunil | last post by:
Hi, We have lot of c and fortran archive libraries that have complex dependencies. We have different server tasks that use some of these libraries. We have developed a tool inhouse that links...
11
by: dskillingstad | last post by:
I've been struggling with this problem for some time and have tried multiple solutions with no luck. Let me start with, I'm a novice at Access and I'm not looking for someones help to design my...
5
by: chrisse_2 | last post by:
Hi, All the records in my database will contain at least one picture. At the moment all the images are part of the database as ole objects although the database is way to big and there is only...
1
by: hmiller | last post by:
I'm sorry to populate the server with yet another question about linking multiple tables and queries, howerver I have not been able to find the right criteria. My problem. I am trying to...
2
by: davy d | last post by:
I'm having a problem with an acess form linkin with another form. My index in the main form is Autonumber (Rec#) the 2nd form is called Record# and it is set for text. The link criteria works...
3
by: Robert McEuen | last post by:
Using A2K3, Windows XP I'm handling a many-to-many relationship with a linking table structure as follows (irrelevant fields omitted): tblIssue PK_IssueID (autonumber, primary key) IssueName...
0
by: Tarik Monem | last post by:
I have been working on an all AJAX/DOM web site which is set to go live today and I thought I'd share my discoveries with all of you whom have helped me when I have encountered different issues along...
2
by: rlamber | last post by:
Hello, I have 2 subforms in a Main form, one links fine, the other doesn't. I am trying to link them both to a "tracking ID" on the main form. The Tracking ID is a text field that is a combination...
1
by: Sudhakar | last post by:
i am using a self submitting for using php <form action="<?php echo $_SERVER; ?>" method="POST" id="test2" name="registrationform"> the registration page starts with a lot of terms and other...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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.