Listbox select all using checkbox through Javascript
In this article, we gonna implement selection of all items in listbox using checkbox through javascript.
<script language=”javascript” type=”text/javascript”>
function SelectAllCountry(chkObj) {
var multi = document.getElementById(‘lstcountry’);
if (chkObj.checked)
for (i = 0; i < multi.options.length; i++)
multi.options[i].selected = true;
else
for (i = 0; i < multi.options.length; i++)
multi.options[i].selected = false;
}</script>
<asp:CheckBox ID=”chkcountry” OnClick=”SelectAllCountry(this);”
runat=”server” Text=”Select All” /><asp:ListBox ID=”lstcountry” runat=”server” Rows=”10″ SelectionMode=”Multiple”>
<asp:ListItem Text=”Australia” Value=”Australia”></asp:ListItem>
<asp:ListItem Text=”Germany” Value=”Germany”></asp:ListItem>
<asp:ListItem Text=”Holland” Value=”Holland”></asp:ListItem>
<asp:ListItem Text=”India” Value=”India”></asp:ListItem>
<asp:ListItem Text=”Japan” Value=”Japan”></asp:ListItem>
</asp:ListBox>
M | T | W | T | F | S | S |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Archives
Recent Posts
Categories
Blog Stats
- 291,112 hits
Recent Comments