-
Using id vs. name in an HTML form
Does the "$_POST['searchtype']" works with the 'name = "searchtype" ' or could it be used with the 'id = "searchtype" ' attribute? Thanks in advance for your help.
Last edited by xtiano77; 03-16-2009 at 01:16 AM.
-
-
It will only work with name, but you can use both if you want. It makes no logical sense though. If you would like to, make sure there is no other element with the same id. Just to say, the id doesn't affect the outcome in any form or way.
Last edited by magicyte; 03-16-2009 at 01:15 AM.
-
-
Thank you Chris for your prompt reply. I understand what you are saying about it not making sense. I was just trying to find out if it worked with the "id" attribute so I can write "Strict" XHTML if needed. Thanks again.
-
-
No, it doesn't work with the id attribute. Simple as that. I'd already said "It will only work with name", just to let you know.
-
-
Names are used as the names of the parameters, and may be non-unique (to allow for checkbox groups, radio button groups, and element arrays); IDs are used to refer to the element within the document (e.g. from Javascript), and must be unique.
Probably you shouldn't be worrying about XHTML compatibility at the moment. IE doesn't yet support XHTML, so it is not feasible for most applications.
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks