Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9239941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:06:14+00:00 2026-06-18T08:06:14+00:00

in my application I have a checkbox list. Listed below is the html for

  • 0

in my application I have a checkbox list. Listed below is the html for the checkbox list, as well as the vb code that bind it on load of the page it is located on.

<asp:CheckBoxList Runat="server" id="chklistTeams" RepeatColumns="7" RepeatDirection="Horizontal"
                        CellPadding="4" Font-Size="7pt"></asp:CheckBoxList>

Below is the VB to bind the checkboxlist

myCmd.CommandText = "Select id, title from teams"
Dim DS As SqlDataReader
DS = myCmd.ExecuteReader
chklistTeams.DataValueField = "id"
chklistTeams.DataTextField = "title"
chklistTeams.DataSource = DS
chklistTeams.DataBind()
DS.Close()

When a save button is hit a javascript function is called. Here is the part of the function that is called that should get us the value of the items.

var checkList = document.getElementById('chklistTeams');
var checkBoxList = checkList.getElementsByTagName("input");
var checkBoxSelectedItems = new Array();

for (var i = 0; i < checkBoxList.length; i++) {
    if (checkBoxList[i].checked) {
        checkBoxSelectedItems.push(checkBoxList[i].value);
        alert('checked - checkBoxList[i]: ' + checkBoxList[i].value)
    }
}

All the values getting stored to the array (tested with the alert) – are coming back with the value “on” – so I then checked the html of the checkboxes in this list, here was the result for one of the checkboxes

<input name="chklistTeams:21" id="chklistTeams_21" type="checkbox" value="on"/>

I am sure the values are being binded correctly to the list – because in the old way of getting their values, you get the correct integer value for the item – listed below is that VB code that used to handle this (and returned a string of integers, depending on how many boxes were checked – did not return a list of the value “on”). I need to be able to get this via javascript for another modification we are making on this page where we must now save using PageMethods and can’t use this on the back end with a public shared function

VB code that will get the right values of checked items in checkboxlist

    For Each li In chklistTeams.Items
        If li.Selected = True Then
            strTeamList = strTeamList & li.Value & ","
            bolTeamSelected = True
        End If
    Next
    If bolTeamSelected = True Then
        strTeamList = strTeamList.Substring(0, strTeamList.Length - 1)
    End If

Can anyone see why the javascript way to get the values is giving me “on” instead of the integer value like the VB way does? Thanks again for your help. Again – this must be done in JS – can’t use the VB code behind way due to the function being public and shared. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:06:16+00:00Added an answer on June 18, 2026 at 8:06 am

    Found a solution to this, made global shared array, on load populated the array with the id values, then through javascipt i was able to get the index of the checked items – can then go to the array at that same index to get id value for later use.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in a ASP.net C# application I have a Checkbox with a custom css. the
I have a CheckBox in my application that is using the TriState mode. The
I have a .NET application that contains a checkbox (System.Windows.Forms.Checkbox). This component (WindowsForms10.BUTTON.app.0.378734a1) is
I'm developing a jsp/serlvet application. I have a page with a list of inputs
I have an ASP.NET MVC Web Application that interacts with a SQL Server 2008
I have an existing ASP.NET MVC 2 application that I've been asked to extend.
I have a ListView in WPF Application with CheckBox inside. I am filling that
I have a web application(ASP.NET2.0 C#). Within it, I have a div that contains
In my WPF application I have a CheckBox whose IsChecked value is bound to
In my application I have methods which returns a control (checkbox, radiobutton, textbox) but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.