Disclaimer: I am not a professional, well, anything. But definitely not a professional JavaScripter. I’ve made a few financial calculators and a few usabilty tweaks (the tweaks I got from the Web, but I took the time to understand them and move things around to my liking).
So I’ve been tasked with making a calculator to calculate (obviously) how much you can get from the Saver’s Credit. Easy enough. If you know your Adjusted Gross Income and your Net Contributions for the year, as well as third-grade math, then you should have no problem figuring it out. To produce, it really only takes the basics of HTML and JavaScript.
So, I start it up from scratch. Very simple, only the basic functionality. Doesn’t work. JavaScript console keeps giving me errors like, “form not defined”, and “form has no properties”. Strange, so I do a little hunting. I find a couple resources that indicate I’m using forms and JavaScript all wrong. I completely understand the reasoning. However, what I don’t understand is the fact that I have a relatively huge calculator that does it the “wrong” way, but it works perfectly and in all browsers I’ve tested it on.
I understand that JavaScript needs to know how to use the form in the HTML section. It seems you either need to use:
document.forms[0].whatever
…if you have only one form to speak of, or you need to name the form and call it in the function, thusly:
myForm.whatever
However, I have the generic:
form.whatever
…but down in the HTML section, where I call the function to be used, instead of something like:
onClick="functionName(this)"
…I use:
onClick="functionName(this.form)"
…and it works perfectly.
So, is this something kinda new or something on it’s way to being deprecated?