I can't seem to get my function right.....It's a tuition calculator. At this point the residency and semesters don't matter. It's just credits * credit cost, but it keeps returning NaN.
No. Your function is defined as:
which expects two arguments which it will multiply. If you pass nothing, it will multiply undefined by undefined and the result is clearly not a number (expressed as NaN).
Bear Bibeault wrote:No. Your function is defined as:
which expects two arguments which it will multiply. If you pass nothing, it will multiply undefined by undefined and the result is clearly not a number (expressed as NaN).
Sorry I'm just a little confused by what you mean. In my mind, I set the variables as numbers. I appreciate your help, but I don't exactly know what you mean.
No, those variables are undefined in the onchange handler.
It seems you are just guessing at this point; you need to ask yourself what values you want to actually pass into the function. When onchange triggers, what is it you actually want to have happen?
Bear Bibeault wrote:No, those variables are undefined in the onchange handler.
It seems you are just guessing at this point; you need to ask yourself what values you want to actually pass into the function. When onchange triggers, what is it you actually want to have happen?
Not guessing just trying to problem solve. I did some more research and made just changes, but am still at an I'm at an impasse.
Bear Bibeault wrote:No, those variables are undefined in the onchange handler.
It seems you are just guessing at this point; you need to ask yourself what values you want to actually pass into the function. When onchange triggers, what is it you actually want to have happen?
In order to use getElementById, the element must have an id. The name is not the same as an id. (name is only used for form submission, so you don't really even need one here.)
There is also getElementsByName if you want to continue to use names.
Bear Bibeault wrote:In order to use getElementById, the element must have an id. The name is not the same as an id. (name is only used for form submission, so you don't really even need one here.)
There is also getElementsByName if you want to continue to use names.
Yes, I remember that now, but nothing is happening when I hit the button.