hey i have just started a javascript class in school, i am having a small problem with a code...if anyone can help with this please help....it will not display anything....
also the reason it is set up like this is because the book said to do it like this...here is what the book said, and below that is what i have came up with...
-----------------------------------------
excerpt from book:
-----------------------------------------
Modify the statements in the following script section so that the variable statements are contained within a function named payroolTaxes(). The function should contain two parameters: federal and state. Instead of assigning literal values to the federalRate and stateRate variables, assign the values that are passed to the federal and state parameteres. Print the value of the federalRate and stateRate variables using write() and writeln() methods. Following the payrollTaxes() function definition, call the payrollTaxes() function and pass to it a value of .28 for federal taxes and .05 for state taxes. Save the program as Payroll.html:
<HTML>
<HEAD>
<TITLE>Payroll</TITLE>
<SCRIPT LANGUAGE=javascript>
<!-- HIDE FROM NON-JAVA
var federalRate = .28;
var stateRate = .05;
// STOP HIDING FROM NON-JAVA
</SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>
-----------------------------------------
now here is the code i have came up with by what the book said to do:
----------------------------------------------------------------
<HTML>
<HEAD>
<TITLE>Payroll</TITLE>
<SCRIPT LANGUAGE=javascript>
<!-- hide from non-java enabled browsers
function payrollTaxes(a, b)
{
var federalRate;
var stateRate;
federalRate = a;
stateRate = b;
}
// stop hiding from non-java enabled browsers
</SCRIPT>
</HEAD>
<BODY>
<SCRIPT LANGUAGE=javascript>
<!-- hide from non-java
var a;
var b;
a = .28;
b = .05;
payrollTaxes(a, b);
document.write(federalRate);
document.write(stateRate);
// stop hiding from non-java
</SCRIPT>
</BODY>
</HTML>
also the reason it is set up like this is because the book said to do it like this...here is what the book said, and below that is what i have came up with...
-----------------------------------------
excerpt from book:
-----------------------------------------
Modify the statements in the following script section so that the variable statements are contained within a function named payroolTaxes(). The function should contain two parameters: federal and state. Instead of assigning literal values to the federalRate and stateRate variables, assign the values that are passed to the federal and state parameteres. Print the value of the federalRate and stateRate variables using write() and writeln() methods. Following the payrollTaxes() function definition, call the payrollTaxes() function and pass to it a value of .28 for federal taxes and .05 for state taxes. Save the program as Payroll.html:
<HTML>
<HEAD>
<TITLE>Payroll</TITLE>
<SCRIPT LANGUAGE=javascript>
<!-- HIDE FROM NON-JAVA
var federalRate = .28;
var stateRate = .05;
// STOP HIDING FROM NON-JAVA
</SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>
-----------------------------------------
now here is the code i have came up with by what the book said to do:
----------------------------------------------------------------
<HTML>
<HEAD>
<TITLE>Payroll</TITLE>
<SCRIPT LANGUAGE=javascript>
<!-- hide from non-java enabled browsers
function payrollTaxes(a, b)
{
var federalRate;
var stateRate;
federalRate = a;
stateRate = b;
}
// stop hiding from non-java enabled browsers
</SCRIPT>
</HEAD>
<BODY>
<SCRIPT LANGUAGE=javascript>
<!-- hide from non-java
var a;
var b;
a = .28;
b = .05;
payrollTaxes(a, b);
document.write(federalRate);
document.write(stateRate);
// stop hiding from non-java
</SCRIPT>
</BODY>
</HTML>