How To Create Select All Option From Dropdown?
I am having problem in my search box, actually i have created a search box for multiple selection and it is working properly,
Solution 1:
try this
Jquery Code:
$('#selectall').click(function() {
$('#countries option').prop('selected', true);
});
Live Demo :
Solution 2:
You can achieve this using jQuery :
EDIT :- You can select multiple value by pressing Ctrl
button of your keyboard and you can get those value using print_r($_POST['countries']);
<select name="countries" id="countries" MULTIPLE size="8">
<option value="all">Select all</option>
<option value="UK">UK</option>
<option value="US">US</option>
<option value="Canada">Canada</option>
<option value="France">France</option>
<option value="India">India</option>
<option value="China">China</option>
</select>
jQuery :
<script>
$(document).ready(function()
{
$('#countries').change(function() {
if($(this).val() == 'all')
{
$('#countries option').prop('selected', true);
}
});
});
</script>
Working Demo
Post a Comment for "How To Create Select All Option From Dropdown?"