- View Offline
- Exercise Files
- Code Practice
- [Voiceover] In this video we're going to look at…how to access the value of a select box.…So we're going to look at this state field now.…It's a select box with a few different values.…And I'm going to open my console again.…The way to access the value of these fields…in modern browsers is just as easy as it is for text fields.…If I right click this state field to select it…in my web inspector,…I'm gonna get its ID by double clicking here…as hyphen state,…and now in my console I can use…document.getElementBYId…pass in the ID and look at its value.…
Which currently is an empty string…because, well, nothing is selected.…If I select California and try it again,…I get back CA.…Now notice the value that I'm getting…is not the label that's shown here.…Why is that?…Back here in the elements inspector I can see why.…The structure of the options here in the select box…are a label inside the option tag…and then the value is the value attribute.…
So note that when you have those value attributes set…for your options,…those are the values that you will get back…
- Working with the DOM
- Creating maps with the Google Maps API
Skill Level Beginner
Productivity Tips for Web Designerswith Sue Jenkins5h 25m Appropriate for all
2. Writing and Debugging
3. Working with Forms
4. A Matter of Time
5. Using the Google Maps API
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.