Reputation: 129
this is my select dropdown array ,how can i have check box in front of each option ,and limit user to select maximum 3 option using javascript .
<select onclick="document.getElementById('cand_qual4').style.display='none'; " name="oca2[]" id="oca2" multiple="multiple">
<?php
$odrop = array('B ','M C','D','A','L','k','P','I','OTHER');
foreach ($odrop as $odrop1)
{
echo '<option value="' . $odrop1 . '"' . (isset($_POST['oca2']) && $_POST['oca2'] == $odrop1 ? ' selected' : '') . '>' . $odrop1 . '</option>';
}
?>
</select>
Upvotes: 1
Views: 1523
Reputation: 1976
Here's an example plugin with which you could achieve that: http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/
It offers multiselect just as you described via checkboxes.
(Side note: Took me only 2 minutes to google it. Google is your friend ;)
Upvotes: 0
Reputation: 1054
You can't place <input type="checkbox" />
within <select />
elements; you'd have to write some javascript to simulate this functionality.
Upvotes: 1