Working with named form elements


show more Working with named form elements provides you with in-depth training on Developer. Taught by Ray Villalobos as part of the JavaScript: Enhancing the DOM show less
please wait ...

Working with named form elements

Selecting form elements is a little easier because forms can have and additional attribute called Name. Like with document images, the DOM provides a special object called document.forms. That's an array of form elements on the page. You can also get to any form element that has a name a little bit easier. So, let's take a look. I'm going to go over to my website, and I'll click on this Register page. Now from here, you can see that I have a form on the left side of this document. Let me pull up the developer tool by hitting Cmd+Option+I on a Mac, Ctrl+Alt+I on a PC.

And then, I'm going to hit the Escape key to pull up the console, and I'll type in document.forms. Now, that gives me an array of all the forms in the current document. I've only got one form, so it's only returning one item. If I want to get into that element, I can say document forms and then the index. Since this is the first item, I'm going to use the index 0, because ar...

Working with named form elements
Video duration: 3m 39s 2h 3m Intermediate

Viewers:

Working with named form elements provides you with in-depth training on Developer. Taught by Ray Villalobos as part of the JavaScript: Enhancing the DOM

Subjects:
Developer Web
Software:
HTML JavaScript
Author:
please wait ...