I have a question about some JavaScript. I’m trying to make a very very simple calculator. The user enters a number, it processes an equation, then BOOM! They get an answer.
Ok, so here’s a new question. I’ve got a drop down menu on the form. I’d like to run a different function depending on the value of the drop down menu. Is that possible?
Sure it’s possible. Just taking a brief look at your page you could do something like…
When the button is clicked for calculate you call the function lmr100(calc). In that function check the value of the drop down menu. Depending on that value, select the function that you want to use for the calculation…
There aren’t any checks in there to make sure the values being input are numerical, but that should be done to prevent errors. A simple regular expression test could look for number characters and the . and - (for decimal values and negative values).