New Feature: Playlist Center! Pick a topic and let our playlists guide the way—like a learning mixtape.

Start learning with our library of video tutorials taught by experts. Get started

HTML5 Projects: Engaging Ecommerce
Illustration by

Exploring highlighted HTML5, CSS3, and JavaScript technologies


From:

HTML5 Projects: Engaging Ecommerce

with Joseph Lowery

Video: Exploring highlighted HTML5, CSS3, and JavaScript technologies

Before we get into actually building a project, I want to take a few moments to talk about each of the key technologies we are using. In all, we're going to be targeting three different technologies: the range form element, drag and drop, and localStorage. Let's start with the form element range. Here is the basic code for a range form element. As you can see, it's an input tag where the type is set to range. And there are several other attributes that you need to include.

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
please wait ...
HTML5 Projects: Engaging Ecommerce
37m 29s Intermediate Nov 06, 2012

Viewers: in countries Watching now:

The HTML5 Projects series combines HTML5, CSS3, and recent JavaScript API technologies to work—enhancing your web projects with interactivity and multimedia. This installment shows you how to build features that allow visitors to your online store to filter their selections interactively via sliders, drag items onto wish lists, and automatically save them locally. Author Joseph Lowery uses this scenario as an opportunity to introduce concepts such as HTML5 form elements with JavaScript enhancements, local content storage, and drag-and-drop.

Topics include:
  • Including range form elements
  • Modifying the display interactively
  • Establishing JavaScript functions
  • Dragging items to wish lists
  • Storing wish list items locally
  • Saving and retrieving list items
Subjects:
Web User Experience Ecommerce Web Design Projects
Software:
HTML JavaScript CSS
Author:
Joseph Lowery

Exploring highlighted HTML5, CSS3, and JavaScript technologies

Before we get into actually building a project, I want to take a few moments to talk about each of the key technologies we are using. In all, we're going to be targeting three different technologies: the range form element, drag and drop, and localStorage. Let's start with the form element range. Here is the basic code for a range form element. As you can see, it's an input tag where the type is set to range. And there are several other attributes that you need to include.

Minimum is now set to 0 in our example, maximum I have set at a 100, and then value is set to 50. Wherever you set the value is where the slider handle will appear to be on the range control. Now, there is also an optional attribute called step. Once you declared the step value, your range control will move in those increments. There is decent browser support for the range form element. Current versions of Chrome, Safari, and Opera already supporting it, and soon Internet Explorer 10.

The only major holdout is Firefox, which currently displays just a text field which the user can enter a value into if they choose. However, there is no interactive slider that they can move back and forth. One hopeful sign: I have noted in the Firefox development circles that they do seem to be working on this feature for some time in the future. If you are unsure of what browsers are supported at what level, I heartily recommend going to caniuse.com, and once you are there, just search for range.

Let me show you what the range input type looks like in Chrome. As you can see, here is that same code that we had: the range from 0 to 100 that starts off at 50. Now, it's pretty obvious that there is one big limitation to the current specification and browser implementation, and that is there is no associated value field to indicate what the slider is representing. It is, however, relatively easy to implement, as you'll see during our project, and I do want to point out there is at least one other ready-made option, which you can find on the jquerytools.org site.

Next up, let's take a look at drag and drop. Drag and drop has two different aspects to it: one minor but critical one on the HTML5 side and a much more robust series of options with the JavaScript API. On the HTML5 side all you need to do is to put in draggable=true into any object that you want to be able to drag. With JavaScript there are seven different events, covering everything from dragstart to drop.

There is one key related object, and that's the dataTransfer object. This is used for, as the name implies, transferring information from a dragged object to a dropped one. So you set the data transfer object and the drag start event and then it's read in the drop event. The third technology used in this project is localStorage. localStorage is really very straightforward to use, and it adds a state to websites without delving into server-side coding.

Unlike with cookies, which is another way web developers have handled the state issue, local storage is handled through the browser cache. Significantly, it also has a much larger limit, as opposed to cookies. It's basically a name/value pair structure, and while there are ways around it-- primarily using JSON--you're normally storing and retrieving strings. There are essentially two simple commands. First localStorage.setItem. Here the first of the two arguments is the name of the item to be stored and the second is its value.

The second command, getItem, just uses one argument, and that's of course the name of the item you want to retrieve. Browser support for local storage is really rocking. You can find all the details on caniuse.com, under local storage. As you can see, it's been supported for quite some time, including all the way back to Internet Explorer 8. So those are the tools we get to play with as we enhance the user experience for an ecommerce catalog, starting in the next chapter.

There are currently no FAQs about HTML5 Projects: Engaging Ecommerce.

 
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.
Upgrade now


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

join now Upgrade now

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.


Mark all as unwatched Cancel

Congratulations

You have completed HTML5 Projects: Engaging Ecommerce.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Notes cannot be added for locked videos.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.