Spencer
Spencer

Reputation: 22370

Drop Down Menu Where All the Elements are Check Boxes

I am trying to create a drop-down menu where all the options in the drop menu are check boxes. The motivation here is so that the user can easily select multiple options in the drop-down. Based on what they select I need to parametrize the form and make an Ajax request.

Upvotes: 1

Views: 3489

Answers (4)

Wex
Wex

Reputation: 15695

<label> elements make it incredibly simple to make menus like this.

<ul>
  <li>
    <label for="item-1">
      <input type="checkbox" name="item" value="1" /> 
      <span>Item 1</span>
    </label>
  </li>
  <li>
    <label for="item-2">
      <input type="checkbox" name="item" value="2" /> 
      <span>Item 2</span>
    </label>
  </li>
  <li>
    <label for="item-3">
      <input type="checkbox" name="item" value="3" /> 
      <span>Item 3</span>
    </label>
  </li>
  ...
</ul>

The .live() function is very useful for sending $_POST requests to the server.

Note that adding padding to your <li> elements or margin to your <label> will make this method less effective.

Upvotes: 0

ipr101
ipr101

Reputation: 24236

You could try one of these two -

http://www.sexyselect.net

or

http://code.google.com/p/jquery-asmselect/

Upvotes: 1

Dan Short
Dan Short

Reputation: 9616

A quick google for jQuery Multiselect returned a jQuery UI plugin as the first result.

Upvotes: 0

Related Questions