Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

another question

Status
Not open for further replies.

ameslee

Programmer
Feb 12, 2006
34
0
0
AU
as you can see im not really good at this, can someone please help me with this one 2

<html>
<head>
<title>Tax Application</title>
<script type = "text/VBScript">
option explicit
function calculate()
dim intsalary, inttotaltax, intnet, intgross, intrate, blnNumber
inttotaltax = document.frmtax.txttotaltax.value
intnet = document.frmtax.txtnet.value
intgross = document.frmtax.txtgross.value
intsalary = document.frmtax.txtsalary.value
blnNumber = isNumeric(intsalary)
if (blnNumber = false) then
window.alert("Please enter a value")
else
intgross = (52 * intsalary)
if intsalary<6001 then
intrate="0"
else if intsalary=>21600 then
intrate="0.17"
else if intsalary=<58000 then
intrate="0.30"
else if intsalary=<70000 then
intrate="0.42"
else if intsalary=>70001 then
intrate="0.47"

inttotaltax = (intsalary * intrate)
document.frmtax.txttotaltax.value = FormatCurrency(inttotaltax,2)
intnet = (intsalary - inttotaltax)
document.frmtax.txtnet.value = FormatCurrency(intnet,2)
document.frmtax.txtgross.value = FormatCurrency(intgross,2)
end if
end if
end function
</script>
</head>
<body>
<h1>Calculate Annual Tax</h1>
<form method="post" name="frmtax" action="javascript:void(0)"> <p>
Enter your weekly salary here:<input type="text" name="txtsalary" size="28"><br>
<input type="submit" value="Calculate Tax" name = "btncalc" onClick = "calculate()"><br>
Annual Gross Income:<input type="text" name="txtgross" size="28"><br>
Annual Net Income:<input type="text" name="txtnet" size="28"><br>
Total Tax for the Year:<input type="text" name="txttotaltax" size="28"><br>
</form>
</body>
</html>

thanks!
 
Same answer to your other thread. What's the error? We can read your script, just don't like to do so without you properly described what the problem is.
 
this one isnt really doing anything, theres an error saying expected if line 34 which is the end function

thanks again
 
remove spcaes in else if
Should look like elseif

Or do a Select Case statement.
 
ive tried putting the else if together, didnt work, can you give me an idea how the select case should look

thanks
 
[tt]<html>
<head>
<title>Tax Application</title>
<script type = "text/VBScript">
option explicit
function calculate()
dim intsalary, inttotaltax, intnet, intgross, intrate, blnNumber
inttotaltax = document.frmtax.txttotaltax.value
intnet = document.frmtax.txtnet.value
intgross = document.frmtax.txtgross.value
intsalary = document.frmtax.txtsalary.value
blnNumber = isNumeric(intsalary)
if (blnNumber = false) then
window.alert("Please enter a value")
else
intgross = (52 * intsalary)
if intsalary<6001 then
intrate="0"
[red]elseif[/red] intsalary=>21600 then intrate="0.17"
[red]elseif[/red] intsalary=<58000 then intrate="0.30"
elseif intsalary=<70000 then intrate="0.42"
elseif intsalary=>70001 then intrate="0.47"
[red]end if[/red]

inttotaltax = (intsalary * intrate)
document.frmtax.txttotaltax.value = FormatCurrency(inttotaltax,2)
intnet = (intsalary - inttotaltax)
document.frmtax.txtnet.value = FormatCurrency(intnet,2)
document.frmtax.txtgross.value = FormatCurrency(intgross,2)
[red]'[/red]end if
end if
[green]'At present you don't want to submit, you've not proper action
'in case at later time you want to submit with proper action, take this out
window.event.returnvalue=false[/green]
end function
</script>
</head>
<body>
<h1>Calculate Annual Tax</h1>
[green]<!-- no good
<form method="post" name="frmtax" action="javascript:void(0)"> <p>
-->[/green]
<form method="post" name="frmtax" [red]onsubmit="calculate()"[/red]> <p>
Enter your weekly salary here:<input type="text" name="txtsalary" size="28"><br>
[green]<!-- no good
<input type="submit" value="Calculate Tax" name = "btncalc" onClick = "calculate()"><br>
-->[/green]
[red]<input type="submit" value="Calculate Tax" name = "btncalc">[/red]<br>
Annual Gross Income:<input type="text" name="txtgross" size="28"><br>
Annual Net Income:<input type="text" name="txtnet" size="28"><br>
Total Tax for the Year:<input type="text" name="txttotaltax" size="28"><br>
</form>
</body>
</html>
[/tt]
 
'At present you don't want to submit, you've not proper action
'in case at later time you want to submit with proper action, take this out
window.event.returnvalue=false

if it is taken out, it looks like it does the calculation, displays it and clears the form in a matter of a second, but then if you press back the calculation is displayed.

can someone plese explain this statement, thanks again
 
ok another question, just realise something while testing, that the user is meant to be entering there weekly salary and not a yearly salary. When i enter a weekly salary it doesnt display the correct net income due to it not calculating the tax. Can anyone tell me why and how to fix this? Thanks!

 
Biz logic is what you have to figure out yourself, otherwise how do you come up with the script?

>[tt]intgross = (52 * intsalary)[/tt]
It seems intgross is the yearly salary. So the interest rate if-elseif-end if part, should you not change intsalary to intgross, like this.
[tt] if int[red]gross[/red]<6001 then intrate="0"[/tt]
etc etc... The rest you have to figure out yourself following the same reasoning.
 
One more hint is that intrate is annual rate for 360-day year. When you calculate the inttotaltax, either you meant total annual tax, in that case, it is:
[tt]inttotaltax = (int[red]gross[/red] * intrate) [/tt]
or total 7-day tax which would be:
[tt]inttotaltax = (intsalary * intrate[red]/52[/red]) [/tt]
without taking into account compound rate/present value... You check the overall correctness of the logic.
 
By 360-day year, I meant 364-day year. If not, you have to adjust again for the slight difference to 365-whatever-day year.
 
guess what everyone, i got it, thanks to tsuii, thank you once again!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top