...

View Full Version : my last code ever, PLLZZZ HELP!!!



Bojangles69
05-09-2006, 03:02 AM
i dont think its problem with syntax, i think its the order of the code. but this is the last program i have to do ever for college and i cant figure it out. last day is tommorow and i can't figure out what im doing wrong. i just need to be able to enter the information and have the 3 calculations execute and move the information to the right column. the mathematical calculations are to figure out the tax. but if anyone sees anything wrong could you please tell me what, thanks a lot.
i do the form code first, than call a function on the submit button, but the information won't transfer..



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Car Registration </TITLE>

</HEAD>
<BODY bgcolor=tan test=black>
<h1><center><b>NJDMV - Trenton NJ</b></center>
<hr><hr>
</h1>
<center>

<form name=carForm>
<table border=4>
<tr>
<td></td>
<td><center>INPUT</td>
<td><center>OUTPUT</td>
</tr>
<tr>
<td>Owner</td>
<td><input type="text" name="ownerIn"></td>
<td><input type="text" name="ownerOut"></td>
</tr>
<tr>
<td>Vehicle Model</td>
<td><input type="text" name="modelIn"></td>
<td><input type="text" name="modelOut"></td>
</tr>
<tr>
<td>Vehicle Type</td>
<td><input type="text" name="TypeIn"></td>
<td><input type="text" name="TypeOut"></td>
</tr>
<tr>
<td>VehicleWeight</td>
<td><input type="text" name="weightIn"></td>
<td><input type="text" name="weightOut"></td>
</tr>
<tr>
<td>Type Use</td>
<td><input type="text" name="useIn"></td>
<td><input type="text" name="useOut"></td>
</tr>
<tr>
<td>Price</td>
<td><input type="text" name="priceIn"></td>
<td><input type="text" name="priceOut"></td>
</tr>
<tr>
<td>Registration</td>
<td></td>
<td><input type="text" name="regOut"></td>
</tr>
<tr>
<td>Tax Levy</td>
<td></td>
<td><input type="text" name="levyOut"></td>
</tr>
<tr>
<td>Weight Tax</td>
<td></td>
<td><input type="text" name="wtaxOut"></td>
</tr>
<tr>
<td>Insurance</td>
<td></td>
<td><input type="text" name="insOut"></td>
</tr>
<tr>
<td>Registration Cost</td>
<td></td>
<td><input type="text" name="rCostOut"></td>
</tr>
<tr>
<td>Federal Tax</td>
<td></td>
<td><input type="text" name="fTaxOut"></td>
</tr>
<tr>
<td>Total Due</td>
<td></td>
<td><input type="text" name="totalOut"></td>
</tr>
<tr>
<td></td>
<td><center><input type="button" value="SUBMIT"
onClick="carFunction()"></td>
</tr>
</table>
</form>
<script>
var ownerIn
var ownerOut
var modelIn
var modelOut
var typeIn
var typeOut
var weightIn
var weightOut
var useIn
var useOut
var priceIn
var priceOut
var regOut
var levyOut
var wtaxOut
var insOut
var rCostOut
var fTaxOut
var totalOut
function carFunction()
{
fTaxOut=priceIn*.02
}
if (ownerIn="P")
{
levyOut=priceIn*.05
wtaxOut=weightIn*.01
inOut=priceIn*.01
}
else
{
levyOut=priceIn*.07
wtaxOut=weightIn*.03
inOut=priceIn*.02
}
regOut=levyOut+wtaxOut+inOut
totalOut=fTaxOut+regOut
ownerOut=Document.carForm.ownerIn.value.
modelOut=Document.carForm.modelIn.value.
typeOut=Document.carForm.typeIn.value.
weightOut=Document.carForm.weightIn.value.
useOut=Document.carForm.useIn.value.
priceOut=Document.carForm.priceIn.value.
regOut=Document.carForm.regOut.value.
levyOut=Document.carForm.levyOut.value.
wtaxOut=Document.carForm.wtaxOut.value.
insOut=Document.carForm.insOut.value.
rCostOut=Document.carForm.rCostOut.value.
fTaxOut=Document.carForm.fTaxOut.value.
totalOut=Document.carForm.totalOut.value.
</script>
</BODY>
</HTML>

Bojangles69
05-09-2006, 03:20 AM
and you definently made need to transfer into editplus or something to run the program so you can understand it what it does.. thanks again.

Bojangles69
05-09-2006, 05:48 AM
i guess noone can figure out why its not working.. bump

bigtiger
05-09-2006, 06:39 AM
hi, take a look of this :)


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Car Registration </TITLE>
</HEAD>
<BODY bgcolor=tan test=black>
<h1><center><b>NJDMV - Trenton NJ</b></center>
<hr><hr>
</h1>
<center>

<form name=carForm>
<table border=4>
<tr>
<td></td>
<td><center>INPUT</td>
<td><center>OUTPUT</td>
</tr>
<tr>
<td>Owner</td>
<td><input type="text" name="ownerIn"></td>
<td><input type="text" name="ownerOut"></td>
</tr>
<tr>
<td>Vehicle Model</td>
<td><input type="text" name="modelIn"></td>
<td><input type="text" name="modelOut"></td>
</tr>
<tr>
<td>Vehicle Type</td>
<td><input type="text" name="TypeIn"></td>
<td><input type="text" name="TypeOut"></td>
</tr>
<tr>
<td>VehicleWeight</td>
<td><input type="text" name="weightIn"></td>
<td><input type="text" name="weightOut"></td>
</tr>
<tr>
<td>Type Use</td>
<td><input type="text" name="useIn"></td>
<td><input type="text" name="useOut"></td>
</tr>
<tr>
<td>Price</td>
<td><input type="text" name="priceIn"></td>
<td><input type="text" name="priceOut"></td>
</tr>
<tr>
<td>Registration</td>
<td></td>
<td><input type="text" name="regOut"></td>
</tr>
<tr>
<td>Tax Levy</td>
<td></td>
<td><input type="text" name="levyOut"></td>
</tr>
<tr>
<td>Weight Tax</td>
<td></td>
<td><input type="text" name="wtaxOut"></td>
</tr>
<tr>
<td>Insurance</td>
<td></td>
<td><input type="text" name="insOut"></td>
</tr>
<tr>
<td>Registration Cost</td>
<td></td>
<td><input type="text" name="rCostOut"></td>
</tr>
<tr>
<td>Federal Tax</td>
<td></td>
<td><input type="text" name="fTaxOut"></td>
</tr>
<tr>
<td>Total Due</td>
<td></td>
<td><input type="text" name="totalOut"></td>
</tr>
<tr>
<td></td>
<td><center><input type="button" value="SUBMIT"
onClick="carFunction()"></td>
</tr>
</table>
</form>
<script type="text/javascript">
var ownerIn
var ownerOut
var modelIn
var modelOut
var typeIn
var typeOut
var weightIn
var weightOut
var useIn
var useOut
var priceIn
var priceOut
var regOut
var levyOut
var wtaxOut
var insOut
var rCostOut
var fTaxOut
var totalOut
function carFunction()
{
fTaxOut=priceIn*.02

if (ownerIn="P")
{
levyOut=priceIn*.05
wtaxOut=weightIn*.01
inOut=priceIn*.01
}
else
{
levyOut=priceIn*.07
wtaxOut=weightIn*.03
inOut=priceIn*.02
}
regOut=levyOut+wtaxOut+inOut;
totalOut=fTaxOut+regOut;
ownerOut=document.carForm.ownerIn.value;
modelOut=document.carForm.modelIn.value;
typeOut=document.carForm.TypeIn.value;
weightOut=document.carForm.weightIn.value;
useOut=document.carForm.useIn.value;
priceOut=document.carForm.priceIn.value;
regOut=document.carForm.regOut.value;
levyOut=document.carForm.levyOut.value;
wtaxOut=document.carForm.wtaxOut.value;
insOut=document.carForm.insOut.value;
rCostOut=document.carForm.rCostOut.value;
fTaxOut=document.carForm.fTaxOut.value;
totalOut=document.carForm.totalOut.value;

// this line was added by me //
document.carForm.ownerOut.value = ownerOut;
}
</script>
</BODY>
</HTML>

You can check this thread if you are not family with it:
http://www.codingforums.com/showthread.php?t=34358

Hope this help !!!

boxxer03
05-09-2006, 06:50 AM
Here's some ideas:

1. <form name="carForm"> - its always a good idea to put quotations around the name of any element.

2. <input type="text" name="TypeIn"> and then you use 'var typeIn' - javascript is case sensitive.

3. 'ownerOut=Document.carForm.ownerIn.value.' - i'm not sure what the period after value is supposed to do but you should use a semi-colon (;) there to let javascript know its the end of a line.

4. Debug your stuff using FireFox browser and the JavaScript console included. It will usually give you a good idea of whats wrong.

I never tested the code, but those are some decent ideas to get you started.

boxxer03
05-09-2006, 06:51 AM
oh yeah that winking smilie face was definetly just supposed to be a semi-colon ';'.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum