1. Home
  2. Computing & Technology
  3. JavaScript
photo of Stephen Chapman
Stephen's JavaScript Blog

By Stephen Chapman, About.com Guide to JavaScript since 2004

Limiting Selections

Saturday August 9, 2008
JavaScript bridges the gap between radio buttons and checkboxes.

Radio buttons work perfectly when you want your visitors to select one out of a number of options. They don't help when you want your visitors to more than one but want to limit the number of selections. To allow more than one selection we have to use checkboxes instead. That means that we have to add the code ourselves that will apply a limit to the number of selections instead of having it happen automatically.

Of course we may want more than one group on the same form so we need to adopt a naming convention for our boxes to identify the groups to which they belong. That plus a call to a simple JavaScript function allows us to create groups where the maximum number of selections can be set to whatever value you like.

Limiting Selections
Comments

No comments yet. Leave a Comment

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Explore JavaScript
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. JavaScript

©2009 About.com, a part of The New York Times Company.

All rights reserved.