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

HTML5 Projects: Engaging Ecommerce

Including range form elements


From:

HTML5 Projects: Engaging Ecommerce

with Joseph Lowery

Video: Including range form elements

The first step towards enhancing the user experience of our ecommerce catalog is to add in a form element new to HTML5, the range input type. It's a very straightforward tag with just a few attributes. In this lesson I'll also add in another form element, a basic text input type, so we can eventually display the actual range value as the slider moves. Finally, I'll show you a very cool CSS property that you don't want to implement to help with your slider stylings.

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

Including range form elements

The first step towards enhancing the user experience of our ecommerce catalog is to add in a form element new to HTML5, the range input type. It's a very straightforward tag with just a few attributes. In this lesson I'll also add in another form element, a basic text input type, so we can eventually display the actual range value as the slider moves. Finally, I'll show you a very cool CSS property that you don't want to implement to help with your slider stylings.

So here's what the page looks like at this current stage. You can see over on the right, under the Price Slider area, there is nothing there. So now let's switch over to our code editor. So I am going to scroll down to about line 67 here, where I have a little handy placeholder, insert range input type here. Let's delete that, and now I'll put in my code for the input tag, starting with input. I'm going to enter an id that we'll use later in our JavaScript routines, and let's just call this slider.

Next, we'll enter in the type for this input tag, and the type is going to be of course range. We want to enter in a number of different attributes now. Let's put in our minimum first. And I'm going to set the min to 50. We don't want to make our artwork too cheap. And we also made a maximum. So max, and let's make that 400 or too expensive. This is a school after all. Next, I'm going to put in an optional argument, step, so we can change how the range increments, and let's put in a step value of 25.

Finally, we want to put in our starting point, and that's handled through the value attribute. In some situations, as in the example I gave in an earlier chapter, you might want it to start right dead center, but in this situation, since what we're going to be doing is filtering out less expensive items, we want to show all of the items to start with. So we're going to place this value at its maximum, the upper limit, 400. Okay, let's close off the input tag. Now that's it for the slider, but as you saw in the previous chapter, there is an issue with the implementation of the slider where there is no real way to show what the range value is.

So let's put in another tag. This will be a simple text field, also an input tag, and this will have an id=rangeValue. That will again help us identify it for JavaScript routines a little further down the line. Next we'll set the type and set that to text. And I'm just going to put in a minimum size, and we'll make it size=2. And then let's close off the tag, and that's done.

So I'm going to save it. Let's head back to the browser for a second, refresh the page, and there is our basic slider and the accompanying text field. Let's bring in some styles to spice it up a bit. I already have the styles created, so all we need to do is to link them in. I am going to move up to the head section of the page, and we'll put this right after our link to the main.css file. So it's link href=, and we'll copy the path, CSS main. As you can see, the code hints begin to come up, so let's take advantage of that and we're going to go to range.css, and it's also going to be rel=stylesheet and we'll use the same media tags: screen and projection.

Okay, we close that tag, and I'll save the file. Now let me open up that particular CSS file, and you can see it has two rules in it: one that targets the input with a type of range and then the other one that goes a little bit further. That's actually targeting the thumb control that moves the sliders. Now most of the properties that you see here, from the second one in each entry on down, are pretty normal, and there is no reason to spend any time on them.

However, the very first entry in both rules, -webkit-appearance, deserves a little bit of explanation. This property allows you to specify a uniform look and feel for all your widgets. However, because we want a custom one, we actually need to set it to none. So let's go over to the browser and take a look. I'll refresh the page, and there is our revised browser. It's pretty, but if you move the control, you see that pretty is all it is.

However, we've got all of our basic elements in place to bring in the very first piece of functionality.

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

Share a link to this course
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

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
Welcome to the redesigned course page.

We’ve moved some things around, and now you can



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.

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