You must Sign In to post a response.
  • Category: ASP.NET

    Get Selected in CheckListbox

    Hi,

    I want to know, how to get the selected values from CheckListBox in Client side(javascript).

    I'm binding the dataset with Name and ID (Name is text field and ID is values), by using the javascript need to get the value ID if Name is selected in CheckListBox.

    Simply need to get the selected values from CheckListBox, but i tried i got the result of Selected Text only javascript but i need the value.

    Regards,
    Sathish
  • #761158
    Hello Sathish,

    Refer the below code :

    <script type = "text/javascript">

    function GetCheckBoxListValues(chkBoxID)
    {
    var chkBox = document.getElementById('<%= checkboxlist1.ClientID %>');
    var options = chkBox.getElementsByTagName('input');
    var listOfSpans = chkBox.getElementsByTagName('span');
    for (var i = 0; i < options.length; i++)
    {
    if(options[i].checked)
    {
    alert(listOfSpans[i].attributes["JSvalue"].value);
    }
    }
    }

    </script>

    Hope this will solve your problem.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"

  • #761174
    Hi,

    Refer below sample

    var checkedDs = document.getElementById('<%=chkSpecialPackNA.ClientID%>').checked;

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/


Sign In to post your comments