1. Technology

Limiting Selections

Introduction

By

Radio buttons are the ideal choice where you want your visitor to select one out of a number of different options but if you want to allow more than one option to be selected then you can't use radio buttons. If we just use checkboxes instead then our visitor will be able to select any number of options between zero and the total number of choices given. There is no button format that just allows two or three out of a larger number of options to be selected.

We can solve this problem by using some simple Javascript code to convert ordinary checkboxes into checkbox groups where there is a maximum number of entries within each group that can be selected.

Let's begin by taking a look at an example so that we can see how this works.

  1. About.com
  2. Technology
  3. JavaScript
  4. Script Library
  5. Function Library
  6. Limiting Selections With JavaScript

©2014 About.com. All rights reserved.