You should always prepend variables, IDs, and classes with something unique to the project or page you're working on, it's just good practice. I've even used my initials on occasion.
I normally do a short acronym for my project followed by an underscore for these types of things.
Look at Google's search form, many of their IDs and classes are prepended with "gs_" and others are named something sufficiently unique so that they won't be accidentally repeated or overwritten.
I've had something like this bite me before. Back in ~2008 one of the browsers introduced support for a new attribute keyword for some HTML element (Maybe "autocomplete"? I wish I could remember.). Since there wasn't one of those defined before, we expando'd it and used the attribute to hook up our functions. When it started to mean something to the browser, it tried to interpret our attribute and freaked out. It took a while to figure out that it was a new feature, but from then on we prefixed $COMPANYNAME_ for all of our attributes.
I like to prefix the element name with the entity name that will be written to. That way, if I have a form that will be writing to the attributes of multiple entities, I know exactly what each represents. If two entities share an attribute name, then the element names will be distinct. For instance, if I have a UI where the user can enter order details and add order lines, then the elements that represent order attributes are prefixed with "order-" and the others are prefixed with "orderLine-". It is tremendously helpful during maintenance.
I ran into this issue a few weeks ago as well. It's a horrible legacy feature that still exists. It's actually even worse. If you have any form elements that are also named after an internal property of the form object, then that input will shadow the native property.
The only way to access it is to clone the form (without children) and then access that property.
I attended a talk on UI design for devs a few months ago. The presenter asked us: "Do any of you run an S&M website? No? Then your buttons shouldn't say submit!"
This seems like a basic namespacing bug in the Javascript DOM: forms should never have allowed input elements to shadow the built-in methods of the form object.
I ran into this gotcha 6-7 years ago when inheriting work on a shopping cart system. It took me at least a full day of debugging. I have used "submitBtn" as a name ever since.
I suppose another incarnation of this problem, albeit less likely to occur in the wild, is to use an input name that is also the id of a different input in the same form.
[+] [-] dm2|12 years ago|reply
I normally do a short acronym for my project followed by an underscore for these types of things.
Look at Google's search form, many of their IDs and classes are prepended with "gs_" and others are named something sufficiently unique so that they won't be accidentally repeated or overwritten.
Also, reserved words:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
http://dev.mysql.com/doc/mysqld-version-reference/en/mysqld-...
http://php.net/manual/en/reserved.keywords.php
http://www.php.net/manual/en/reserved.variables.php
[+] [-] web007|12 years ago|reply
[+] [-] stronglikedan|12 years ago|reply
[+] [-] vivin|12 years ago|reply
The only way to access it is to clone the form (without children) and then access that property.
I asked a question on stackoverflow about it:
http://stackoverflow.com/questions/22942689/form-elements-wi...
[+] [-] zorbo|12 years ago|reply
[+] [-] lucb1e|12 years ago|reply
[+] [-] joezimjs|12 years ago|reply
[+] [-] imjustabill|12 years ago|reply
[+] [-] joezimjs|12 years ago|reply
[+] [-] JoshTriplett|12 years ago|reply
[+] [-] joekrill|12 years ago|reply
[+] [-] prezjordan|12 years ago|reply
Make your (code|life|waffles) simpler?
[+] [-] cryowaffle|12 years ago|reply
[+] [-] toconnor|12 years ago|reply
[+] [-] fvox13|12 years ago|reply
[+] [-] dmethvin|12 years ago|reply
[+] [-] ademarre|12 years ago|reply
[+] [-] lubujackson|12 years ago|reply
$('<input type="submit" style="display:none;">').appendTo("#form").trigger('click'); $("#form" input:last-child").remove();
It adds a second submit button to the form and clicks it, then removes the button. Probably a better way to do this, but it works.
[+] [-] joezimjs|12 years ago|reply
[+] [-] danielweber|12 years ago|reply
[+] [-] joezimjs|12 years ago|reply
[+] [-] bcardarella|12 years ago|reply
[+] [-] joezimjs|12 years ago|reply
[+] [-] user24|12 years ago|reply
[+] [-] user24|12 years ago|reply
[+] [-] mantrax5|12 years ago|reply
And I also .submit() forms via JS.
And I never had this issue...
[+] [-] yahelc|12 years ago|reply
With id="submit", throws a "object is not a function" error. http://jsfiddle.net/nbkHs/
Without, submits just fine: http://jsfiddle.net/B8CV2/1/