Monday 1 May 2017

Get Selected Value of CheckBoxes using jQuery

How to retrieve checkboxes values in jQuery
Description:
In this example we explain that how to get selected checkboxes value using jQuery and javascript in asp.net or how to fetch the selected or checked checkboxes values using jQuery and javascript.or how to retrieve the value of the selected or checked checkbox using jQuery.here we demonstrate that how to use jQuery to get the values of selected checkboxes in asp.net.
Code:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="checkboxgetvalue.aspx.cs"
    Inherits="checkboxgetvalue" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $('input:checkbox[name=locationthemes]:checked').each(function () {
                alert($(this).val());
            });

        });
    </script>
    <title>Get Selected Text Value of checkboxes using jQuery in ASP.Net </title>
</head>
<body>
    <form id="form1" runat="server">
    <input type="checkbox" name="locationthemes" id="checkbox-1" value="2" checked="checked"
        class="custom" />
    <label for="checkbox-1">
        Castle</label>
    <input type="checkbox" name="locationthemes" id="checkbox-2" value="3" class="custom" />
    <label for="checkbox-2">
        Barn</label>
    <input type="checkbox" name="locationthemes" id="checkbox-3" value="5" class="custom" />
    <label for="checkbox-3">
        Restaurant</label>
    <input type="checkbox" name="locationthemes" id="checkbox-4" value="8" checked="checked"
        class="custom" />
    <label for="checkbox-4">
        Bar</label>
    </form>
</body>
</html>




This entry was posted in :

0 comments:

Post a Comment