Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

newbie question - id vs. name

Status
Not open for further replies.

influent

Programmer
Jan 11, 2001
131
US
What is the difference between a control's "ID" parameter and its "NAME" parameter on an HTML form?
 
ID is generally IE-only , if you use name= it will work for ie as well as most other browsers, and i belive it is the standard, use ID if you are using IE only with some client side vbscript , but other than that, they're pretty much the same. Karl Blessing aka kb244{fastHACK}
kblogo.jpg
 
Cool, thanks. I'm going to do ASP and I'd like it to work in Netscape as well as IE, so I'll use the name parameter.
 
If you are working with Active Server Pages, keep your client-side as standard as possible, that means using VBscript on the serverside, but javascript on the client side. Karl Blessing aka kb244{fastHACK}
kblogo.jpg
 
One more question since I've got you hooked to this thread:
Is there an equivalent to IE's "rightmargin" body parameter in Netscape?
T.I.A.
 
They're hardly interchangeable.

In some cases you can get away with name and no id, in others id but and no name.

id is supposed to be used to reference an object from script, while name is primarily intended to label form elements (name/value pairs) for get/post requests.

It is a pain, but in most cases you'll be better off putting both on an element that needs identification, and make them equal to the same string.

The weird thing is even if you use id for scripting, if you don't use name for a group of elements you want to appear as a collection (by using the same name string) then it won't work right.

Someday (soon?) Netscape will go away and the world will be easier for developers - though this is probably not the best of all possible worlds for computer users at large.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top