How to Use the selectedIndex property JavaScript and PHP Forms JavaScript Forms


show more Using the selectedIndex property provides you with in-depth training on Developer. Taught by Ray Villalobos as part of the Validating and Processing Forms with JavaScript and PHP show less
please wait ...

Using the selectedIndex property

Just about all the text fields in an HTML form are input fields. The exceptions are the text area field, which is really just like a text field, and also the select field. The select field is quite another beast, so I wanted to cover how to handle onchange events on select fields. Select fields have a special and very useful property called the selectedIndex property, which shows you the option that a user has selected from its list. So, let's take a look at this form, which we're going to be working on in this movie.

This form just has a single field, and it's a pop up field with a list of some websites. If you take a look at the code, you'll see that the value field for each of those is an actual site. So what I'm going to do is, after the form field, I'm going to add a script tag. And on that script tag, I'm going to target the form. And our field is called reference, so I'll target that. And I'll add an onchange event handler. That&#...

Using the selectedIndex property
Video duration: 2m 30s 2h 51m Intermediate

Viewers:

Using the selectedIndex property provides you with in-depth training on Developer. Taught by Ray Villalobos as part of the Validating and Processing Forms with JavaScript and PHP

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