1

I am new to web development and I have been taking a class through Lynda.com on how to use Dreamweaver CS5. I try to spend most of my time hand coding and use the Dreamweaver tutorial as an intro to HTML. However, I have noticed that when I do use Dreamweaver to enter certain elements in, such as forms, it uses the "name" attribute and not the "id" attribute. From what I have learned, "name" has been abandoned in favor of "id". Is this the case for all tags, such as forms? If so, how can I set Dreamweaver to use "id" in this case, instead of "name"?

Please forgive me if this has already been answered. I searched for it, and did not come across it, but since I am new to Stackoverflow, it might just be that I didnt search correctly.

Thanks so much!

2 Answers2

1

In this case, Dreamweaver is correct. For a server-side programming language to process the form data (as POST or GET data), each form element must have a name="" attribute set.

You can still manually type id="" in the HTML if you need it, but Dreamweaver autogenerating name attributes for form elements is very sensical if the form is to be used.

HTML

<input type="text" name="message1" id="styleme" value="Hey there!" />

CSS

#styleme { font-size: 18px; }

PHP

<?php echo $_POST['message1']; ?>
Chris G.
  • 3,963
  • 2
  • 21
  • 40
1

name attributes are still required for form elements as Chris G. noted up, maps and frames (iframes among them). Check this thread for the example of name usage on iframe.

id is way to uniquely identify DOM element, mostly for styling or scripting purposes.

Community
  • 1
  • 1
jayarjo
  • 16,124
  • 24
  • 94
  • 138