JavaScript Tutorial
I don't want to be discouraging but there are a few errors here. Have you done much html? Have you done any other javascript? Check out the tutorial above and go through that first. Once you make it through that tutorial this should be much easier. I started responding below so you can see some of the stuff that's wrong. I didn't finish though because I found a few more errors and your problems are more just with fundamental understanding than with syntax.
the way you create your function is a little off. maybe javascript is different, as i'm not too familiar with it, but in the languages I use, you can't create a function like that and assign it to a variable. you need to create a function by just getting rid of the "max =" part.
The purpose of a function is to make a block of code that you can call, passing a few arguments with it (in this case, age). Then that function will run and return it's output.
This may not be perfect but it should be closer. Again as I said I don't really know javascript, but i do a lot of programming.
Code:
function maxHeartRate(age)
{
return (220-age);
} Then you make a call to that function below it like this
Code:
max = maxHearRate(21);
your html form is a little off. In particular the onclick belongs as an attribute of your submit button, not it's own html tag.
The last big error, which is like I said more theoretical is the second script. that script wont' run every time the button is clicked. That run's once when the page is loaded. The text won't automatically change whenever max changes. In other words the script won't sit there and wait for it's variables to change and then change the html. Hope that makes sense.