Download multiple select box widget

Demo

Put this into your <HEAD> section

Put this into your <BODY> section

Configuration

You create two multiple selectboxes like this:
<select multiple name="fromBox" id="fromBox">
  <option value="3">Finland</option>
  <option value="4">France</option>
  <option value="6">Mexico</option>
  <option value="1">Norway</option>
  <option value="5">Spain</option>  
  <option value="2">United Kingdom</option>
</select>
<select multiple name="toBox[]" id="topBox">
  <option value="12">Canada</option>
  <option value="13">Germany</option>
  <option value="11">United States</option>
</select>

Then you call a javascript function which initializes the script:
<script type="text/javascript">
createMovableOptions("fromBox","toBox",500,300,'Available countries','Selected countries');
</script>

The arguments to this function are:

  • "fromBox" - the id of the first selectbox(<select multiple name="fromBox" id="fromBox">)
  • "toBox" - the id of the last selectbox(<select multiple name="toBox[]" id="toBox">)
  • 500 - Total width of widget
  • 300 - Total height of widget
  • "Available countries" - Label above first select box
  • "Selected countries" - Label above last select box

Submit the form

When you submit a form, only the selected elements in a select box is submitted. This means that you need some Javascript that selects all the elements in your select box when the form is submitted. This could be an onsubmit event to your form. Example:
<form method="post" action="multiple_select.html" onsubmit="multipleSelectOnSubmit()">

Comments

No one has commented this - be first!

Post your comment

Don't have an avatar? Create one at Gravatar.com.

Confirmation code:

Go to cbolson.com


About/Contact | A good idea? | Submit a script | Privacy notice
© 2005 - 2024 dhtmlgoodies.com