Matt wrote:
I want to know if we need id attribute? Or just name attribute is
fine?
For example:
Name: <input type="text" id="text" name="fname">
This is a matter of personal preference unless:
1. the element is in a form which you are submitting to an asp page, in
which case the name attribute must be set in order for the receiving page to
read its value.
2. the element is part of a group of elements which you need to refer to
with a single identifier. In this case, you should use the name attribute
for the grouping name, leaving the id attribute to be used for a unique name
for each element in the group. Radio buttons and checkboxes are often
created this way.
Otherwise, it's really up to you. My personal preference is to use id to
uniquely identify a single element on a page, and name for form elements and
grouped elements. In script, I will always use the id to refer to a single
element.
This is an HTML/DHTML question and should have been asked in a more
appropriate group (look for a group with "DHTML" in its name, or one of the
..scripting groups depending on which language you wish to use in your
client-side script). ASP (server-side code) knows nothing about element
names or ids.
HTH,
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.