On Mon, Dec 15, 2008 at 9:59 PM, Mike Alsup <[email protected]> wrote:
>
>> > You should never have an element with an id value that does not match
>> > its name value.  Get that straightened out and you'll be fine.
>>
>> That's not true at all. Do you have a reference for that?
>>
>> The id attr. is solely for the DOM, while name is passed to the server.
>
> Yes, that's quite true.  But using different values on the same
> element is a very bad idea.
>
> http://msdn.microsoft.com/en-us/library/ms536437(VS.85).aspx
>
> There are other issues in addition to the problems with getElementById
> mentioned in the linked article above.  For example, both the id and
> name values on form controls are promoted to properties on the form
> element.  This quickly leads to debugging nightmares.

Well, Microsoft's word on what are and are not best practices isn't
worth a hill of beans. However, as it's yet another thing that their
crappy software falls down on, I'll definitely take it into
consideration. Thanks for the pointer.

MS aside, there should be no problem at all with having id & name be
different strings. Take, for example:

<input type="radio" id="whatever_foo" name="whatever" value="foo" />
<input type="radio" id="whatever_bar" name="whatever" value="bar" />

Now, I can't think of any really good reason to need to do that but it
shouldn't break anything. The value that's sent to the server is that
of the element with the "on" state, btw.

Of course, we're talking about MS here. I can't believe that this has
only been fixed with IE8. What a load of crap they put out. Whoever
decided that getElementById() should check the name attr. is an idiot,
IMHO.

As for the OP's missing value in $_POST, I had a look at the HTML4 W3C
docs. Specifically, the part about "successful controls" [1] (those
elements whose values should be sent to the server). It says that:

"If a form contains more than one submit button, only the activated
submit button is successful."

And, since the form.submit() method is circumventing the submit
button, the latter cannot be considered "successful" and so jQuery
does not have a bug with this.

[1] http://www.w3.org/TR/1998/REC-html40-19980424/interact/forms.html#h-17.13.2

Reply via email to