473,320 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to validate the selected value of checkboxlist using javascript

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
3 1218
Dormilich
8,658 Expert Mod 8TB
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
Thank you.. But its too didn't work wit me:(
Jul 29 '16 #3
Dormilich
8,658 Expert Mod 8TB
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

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

Similar topics

2
by: Joey | last post by:
Hi There, I am trying to get the selected value of a listbox when I click a button, everything works ok and I can bind the list and when I have a basic page and click a button to invoke a sub it...
2
by: Greg | last post by:
I have a listbox inside of a DetailsView. There are three departments to choose from, Corporate, Group, Vacation. The listbox is set to SelectionMode="multiple". I think I have this loop setup...
3
by: kang jia | last post by:
hi, now i want to validate numeric value which user filled in in text box, it can have 2 decimal places. what is the regular expression i can use to achieve this? anyone can help? can reply me...
1
by: printline | last post by:
Hello All I'm a newbee to javascript/ajax. I have produced a form, where i want to do some validation on some fields. I have used the spry framework and it works fine. Now, i have a select...
1
by: moose hoss | last post by:
How would I validate this select box using JavaScript? <form action="pizza/data.php" method="post" name="form" onsubmit="javascript:return form_validation();"/> <select name="team"...
1
by: sarvesh1987 | last post by:
am new in C# ASP.NET. I have a problem in CheckBoxList to add selected items in database with multiple rows. I have one page where I insert Product Information in database on submit button. In the...
1
by: nNaveenpal | last post by:
how to validate input type file using javascript for file type and size?
1
by: vigneshm0601 | last post by:
Hi, Here in the below code i need to keep the selected value to be shown. But if i select and update the page the list box always shows the index value "select".I want it to show the selected value....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.