I2izzo
03-06-2012, 12:25 AM
This is a homework assignment I am trying to work on. Simple put my goal is to be able to click a "generate payslip" button and it should pop up "(firstname)(lastname), you will pay (var1*0.2) in federal taxes and (var2*0.1) in state taxes. Then i will add a reset button to the fields. I am NOT asking you to do this for me, i just need some help on what im doing wrong seeing as my teacher refuses to be of any help.
Here is what i got.. dont laugh.
After literally spending hours on the computer trying to find help codes I took out the bulk of trash i had in there because it never worked, but at one point i had something like this
var1 = num1
var2 = num2
var3 = num3
var answer= num3*0.2
var answer2= num3*0.1
Then i tried to include that in my alert box and even tweaked it over and over and either completely eliminated the alert box itself or include all the text in my equation.
Either way, if someone can enlighten me on how to properfly perform a calculation in an alert box i would be ecstatic.
<HTML>
<HEAD>
<center><b>
Here is a pay slip generator that will determine your net annual salary.
Simply type in your first and last name along with gross salary and hit calculate.
Doing this will let you know how much you will end up paying in both Federal and State taxes.
</center></b>
<form action="" method="post" name="GPS">
<p> Enter your First Name:
<input name="num1" type="text" id="num1" size="10" maxlength="10">
</p>
<p> Enter your Last Name:
<input name="num2" type="text" id="num2" size="10" maxlength="10">
</p>
<p> Enter your gross salary:
<input name="num3" type="#" id="num3" size="10" maxlength="10">
</p>
Click this button to calulate your annual net pay!
<script type="text/javascript">
function calculate()
{
alert("You type something");
}
</script>
<input type="button" onclick="calculate()" value="Generate Pay Slip" />
</FORM>
</body>
</html>
</script>
Here is what i got.. dont laugh.
After literally spending hours on the computer trying to find help codes I took out the bulk of trash i had in there because it never worked, but at one point i had something like this
var1 = num1
var2 = num2
var3 = num3
var answer= num3*0.2
var answer2= num3*0.1
Then i tried to include that in my alert box and even tweaked it over and over and either completely eliminated the alert box itself or include all the text in my equation.
Either way, if someone can enlighten me on how to properfly perform a calculation in an alert box i would be ecstatic.
<HTML>
<HEAD>
<center><b>
Here is a pay slip generator that will determine your net annual salary.
Simply type in your first and last name along with gross salary and hit calculate.
Doing this will let you know how much you will end up paying in both Federal and State taxes.
</center></b>
<form action="" method="post" name="GPS">
<p> Enter your First Name:
<input name="num1" type="text" id="num1" size="10" maxlength="10">
</p>
<p> Enter your Last Name:
<input name="num2" type="text" id="num2" size="10" maxlength="10">
</p>
<p> Enter your gross salary:
<input name="num3" type="#" id="num3" size="10" maxlength="10">
</p>
Click this button to calulate your annual net pay!
<script type="text/javascript">
function calculate()
{
alert("You type something");
}
</script>
<input type="button" onclick="calculate()" value="Generate Pay Slip" />
</FORM>
</body>
</html>
</script>