473,810 Members | 3,135 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calculator Code Error? - First Ever Script

2 New Member
[HTML] <html>

<head>

<title></title>
<script type="javascrip t" src="E:\Interne t\positive_gear ing.js">
function positve_gearing () {

var price = form.price.valu e;
var rates = form.rates.valu e;
var bc = form.bc.value;
var rent = form.rent.value ;
var ir = form.ir.value;

var a = (rates/52).toFixed(2);

if (bc > 500)
{
if (bc > 500)
var b = (bc / 52).toFixed(2);
}
else
var b = bc.toFixed(2);


if (rent > 5000)
{
if (rent > 5000)
var c = (rent / 52).toFixed(2);
}
else
var c = rent.toFixed(2) ;

var d = ((price*(ir/100))/52).toFixed(2);

var e = ((((c*50)-(c*50*0.08)-(bc*52)-rates)/price)*100).toF ixed(2);
var f = (e-ir).toFixed(2);
var g = (c-d-b-a).toFixed(2);

form.a1.value = a;
form.b1.value = b;
form.c1.value = c;
form.d1.value = d;
form.e1.value = e;
form.f1.value = f;
form.g1.value = g;


return false;
}
</script>
</head>

<body>



<FORM NAME="myform" ACTION="" METHOD="GET"><t able align="center"
border="1"><tr>

<td align="right">
Purchase Price:
</td>
<td align="left">
<input type="text" name="price" size="6" />
</td></tr><tr>

<td align="right">
Rates:
</td>
<td align="left">
<input type="text" name="rates" size="6" />
</td></tr><tr>

<td align="right">
Body/Corp (weekly or annually):
</td>
<td align="left">
<input type="text" name="bc" size="6" />
</td></tr><tr>

<td align="right">
Rent (weekly or annually):
</td>
<td align="left">
<input type="text" name="rent" size="6" />
</td></tr><tr>

<td align="right">
Interest rate:
</td>
<td align="left">
<input type="text" name="ir" size="6" />
</td></tr><tr>


<td colspan="2" align="center">
<INPUT TYPE="button" NAME="button1" Value="Calculat e" onClick="positi ve_gearing()"></td></tr><tr>

<td align="right">
Rates (weekly):
</td>
<td alig="left">
<input type="text" name="a1" value="" size="6"
readonly="reado nly" /></td></tr><tr>

<td align="right">
Body/Corp (weekly):
</td>
<td alig="left">
<input type="text" name="b1" value="" size="6"
readonly="reado nly" /></td></tr><tr>

<td align="right">
Rent (weekly):
</td>
<td alig="left">
<input type="text" name="c1" value="" size="6"
readonly="reado nly" /></td></tr><tr>

<td align="right">
Weekly Repayments (interest only):
</td>
<td alig="left">
<input type="text" name="d1" value="" size="6"
readonly="reado nly" /></td></tr><tr>

<td HEIGHT="20" align="center"> </td></tr><tr>

<td align="right">
Percent Return:
</td>
<td alig="left">
<input type="text" name="e1" value="" size="6"
readonly="reado nly" /></td></tr><tr>

<td align="right">
Percent Profit/Loss:
</td>
<td alig="left">
<input type="text" name="f1" value="" size="6"
readonly="reado nly" /></td></tr><tr>

<td align="right">
Weekly Profit/Loss:
</td>
<td alig="left">
<input type="text" name="g1" value="" size="6"
readonly="reado nly" /></td></tr><tr>

</table>
</form>



</body>

</html>
[/HTML]
Mar 27 '07 #1
3 1649
r035198x
13,262 MVP
[HTML] <html>

<head>

<title></title>
<script type="javascrip t" src="E:\Interne t\positive_gear ing.js">
function positve_gearing () {

var price = form.price.valu e;
var rates = form.rates.valu e;
var bc = form.bc.value;
var rent = form.rent.value ;
var ir = form.ir.value;

var a = (rates/52).toFixed(2);

if (bc > 500)
{
if (bc > 500)
var b = (bc / 52).toFixed(2);
}
else
var b = bc.toFixed(2);


if (rent > 5000)
{
if (rent > 5000)
var c = (rent / 52).toFixed(2);
}
else
var c = rent.toFixed(2) ;

var d = ((price*(ir/100))/52).toFixed(2);

var e = ((((c*50)-(c*50*0.08)-(bc*52)-rates)/price)*100).toF ixed(2);
var f = (e-ir).toFixed(2);
var g = (c-d-b-a).toFixed(2);

form.a1.value = a;
form.b1.value = b;
form.c1.value = c;
form.d1.value = d;
form.e1.value = e;
form.f1.value = f;
form.g1.value = g;


return false;
}
</script>
</head>

<body>



<FORM NAME="myform" ACTION="" METHOD="GET"><t able align="center"
border="1"><tr>

<td align="right">
Purchase Price:
</td>
<td align="left">
<input type="text" name="price" size="6" />
</td></tr><tr>

<td align="right">
Rates:
</td>
<td align="left">
<input type="text" name="rates" size="6" />
</td></tr><tr>

<td align="right">
Body/Corp (weekly or annually):
</td>
<td align="left">
<input type="text" name="bc" size="6" />
</td></tr><tr>

<td align="right">
Rent (weekly or annually):
</td>
<td align="left">
<input type="text" name="rent" size="6" />
</td></tr><tr>

<td align="right">
Interest rate:
</td>
<td align="left">
<input type="text" name="ir" size="6" />
</td></tr><tr>


<td colspan="2" align="center">
<INPUT TYPE="button" NAME="button1" Value="Calculat e" onClick="positi ve_gearing()"></td></tr><tr>

<td align="right">
Rates (weekly):
</td>
<td alig="left">
<input type="text" name="a1" value="" size="6"
readonly="reado nly" /></td></tr><tr>

<td align="right">
Body/Corp (weekly):
</td>
<td alig="left">
<input type="text" name="b1" value="" size="6"
readonly="reado nly" /></td></tr><tr>

<td align="right">
Rent (weekly):
</td>
<td alig="left">
<input type="text" name="c1" value="" size="6"
readonly="reado nly" /></td></tr><tr>

<td align="right">
Weekly Repayments (interest only):
</td>
<td alig="left">
<input type="text" name="d1" value="" size="6"
readonly="reado nly" /></td></tr><tr>

<td HEIGHT="20" align="center"> </td></tr><tr>

<td align="right">
Percent Return:
</td>
<td alig="left">
<input type="text" name="e1" value="" size="6"
readonly="reado nly" /></td></tr><tr>

<td align="right">
Percent Profit/Loss:
</td>
<td alig="left">
<input type="text" name="f1" value="" size="6"
readonly="reado nly" /></td></tr><tr>

<td align="right">
Weekly Profit/Loss:
</td>
<td alig="left">
<input type="text" name="g1" value="" size="6"
readonly="reado nly" /></td></tr><tr>

</table>
</form>



</body>

</html>
[/HTML]
1.)Java != Javascript so I moved that to the Javascript forum.
2.)When posting code please use code tags like the ones I just added for you there.
3.)What did you say is the problem with your code?
Mar 27 '07 #2
aventerprise
2 New Member
Hi,

Yeah sorry pretty unclear was just in a hurry.

I'm not sure what is wrong with the code, just when i push the button to calculate it comes up with the error: object required for the line

Expand|Select|Wrap|Line Numbers
  1. INPUT TYPE="button" NAME="button1" Value="Calculate" onClick="positive_gearing()"></td></tr><tr>
Mar 28 '07 #3
acoder
16,027 Recognized Expert Moderator MVP
You're trying to access the form with the name "form".

Add this line to the beginning of your function:
Expand|Select|Wrap|Line Numbers
  1. var form = document.forms.myForm;
Also you've spelt "positive" incorrectly (an i is missing).
Mar 29 '07 #4

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

Similar topics

4
1936
by: mwh | last post by:
Hi. If you remember, I posted Expressons Help. Now I am making a calculator with javascript. I can't get this to work: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <title>Calculator</title> <script language="Javascript"> <!-- Begin Hiding var total = 0
1
6947
by: Eric Terrell | last post by:
Folks: I've posted the full source code to C# Programmable Calculator at my website: http://www.personalmicrocosms.com/html/cspcalc.html C# Programmable Calculator is a Reverse Polish Notation (RPN) calculator with custom buttons programmable in C#.
5
6869
by: Steven Smith | last post by:
I was flicking through the windows accesories programs for some inspiration for todays vb challenge when I came accross the calculator program & thought that looks easy I could do that. However it hasn't turned out to be as easy as I first anticipated due to a calculators strange logic I done a bit of research on the web to see what I could come up with and I found this following page which outlines the ideas behind a calculator...
3
15146
by: PieMan2004 | last post by:
Hi, ive been looking for a solid java community to help me when im tearing out my hair :) Basically ive constructed a GUI that has to represent the same look and functions of the typical windows calculator. Ive made 4 classes 2 do this, my reasoning so it was easier to look through( when programming) rather than getting mixed up in my own code! My questions and problems: Ive been messing around with the windows look and feel,...
24
6348
by: firstcustomer | last post by:
Hi, Firstly, I know NOTHING about Javascript I'm afraid, so I'm hoping that someone will be able to point me to a ready-made solution to my problem! A friend of mine (honest!) is wanting to have on his site, a Javascript Calculator for working out the cost of what they want, for example: 1 widget and 2 widglets = £5.00
27
2756
by: David Golightly | last post by:
This is just a quick poll for all you web devs out there: What browsers do you test on/are concerned about compatibility with? Obviously, you're going to test on current-generation browsers such as IE6, IE7, Firefox 1.5/2, Opera 8/9, Safari 2, etc. How old must a browser be before you stop worrying about it? Anybody here still test on IE4? Thanks,
2
6488
by: JasmynGomez | last post by:
This was an assignment for our JAVA class I am still a beginner and my code keeps getting errors, and I am so confused. I've tried every different way I can think of, can someone please take a look and point out some of the errors. Even just point me to the right direction. I've been working on this for 3 days. HELP!!!!! Write a Geometry Calculator that computes the perimeter and area of the following objects: (a) Trapezoid (general...
1
2547
by: clairelee0322 | last post by:
This program doesn't run because some problem with the reduce fraction. My reduce fraction is all right but when I tried to put that in this program, It has some errors. Or maybe the switch menu is wrong? because I put another swith menu in the main switch menu. I guess the problem is In the division - fraction section the error says something like cases are skipped by something.. I don't remember because I only get the chances to use C++...
4
1797
by: Yonih | last post by:
So I am trying to get this Calculator to work. It needs to take in a vaule, and select a shipping Everythin works great except the shipping part. I need it to take the shipping value and add it to the "Downpayment" and also the "Total amount paid" Example: item cost $20.00 , $8.50 shipped selected, Payment 1 = 12 + 8.50 so $20.50 Payments 2-5 = $2.00 Final Payment = $28.50
0
9722
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10644
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10379
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10393
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10124
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4334
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3863
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.