By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,514 Members | 1,308 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,514 IT Pros & Developers. It's quick & easy.

How to validate the selected value of checkboxlist using javascript

P: 19
Hai i want to display the selected values of checkboxlist in an alert in javascript

i'm using following code, but it doesn't work.. please help me...



Expand|Select|Wrap|Line Numbers
  1. function ChkSelectvalue(ckBoxItems) 
  2. {
  3.    try 
  4.  { 
  5.        var chkList = ckBoxItems.getElementsByTagName('input');
  6.        var listOfSpans = ckBoxItems.getElementsByTagName('span');
  7.        var chkList1 = chkList.length;
  8.        for (var j = 0; j < chkList1; j++) {
  9.         if(chkList[j].checked==true)
  10.          {
  11.            alert(listOfSpans[j].innerHTML);
  12.          }
  13.        } 
  14.    } catch (e) { };

Expand|Select|Wrap|Line Numbers
  1. <asp:CheckBoxList CssClass="ddlFont" ID="chkProvider" Width="325px" runat="server"
  2.                                onclick="ChkSelectvalue(this);">
  3.                            </asp:CheckBoxList>

Thanks in advance
Jul 28 '16 #1
Share this Question
Share on Google+
3 Replies


Dormilich
Expert Mod 5K+
P: 8,639
replace line 14 with
Expand|Select|Wrap|Line Numbers
  1. } catch (e) { console.log(e.message); }
and then check the console output.
Jul 28 '16 #2

P: 19
Thank you.. But its too didn't work wit me:(
Jul 29 '16 #3

Dormilich
Expert Mod 5K+
P: 8,639
it's not supposed to make it work, it's supposed to tell you, when an error occurs, so you can fix it.
Jul 29 '16 #4

Post your reply

Sign in to post your reply or Sign up for a free account.