The various answers here have all focussed on different aspects of what's wrong (lurkers: please upvote the helpful ones), so I'll sum them up in a community answer:
It's
else if
(note the space), notelseif
.You've used the variable name
radius
, but then when referencing it you use$radius
. Either is fine, pick one and be consistent. I'll useradius
.Instead of
getElementById("#radius")
, use$("#radius")
. (There were two different problems with the first version: 1.getElementById
is a property ofdocument
, not a global. 2. You don't use a selector with it, just the ID.)You're using
radius
as though it were a number, but it's an object (the DOM element if you usegetElementById
, a jQuery object if you use$()
). So you probably want.val()
there, too. And although JavaScript will convert the string to a number for you when you do things likeradius < 40
, it's usually best to parse it explicitly. So:var radius = parseInt($("#radius").val(), 10); // 10 = base 10
You haven't closed the call to
submit
, you need a);
after the last}
in your code.
Separately, if you're using else if
, you don't need the initial radius >= XX &&
part of the subsequent conditions.