473,320 Members | 2,071 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.

Geting Checkboxlist value in javascript


hai..
am having a checkboxlist..now how do i get the value of the checkbox
that is checked in checkboxlist using javascript?
Thanks in advance....
Regards,
Satheesh

Oct 19 '05 #1
2 13670
What does mean "checkboxlist"? HTML doesn't contain "checkboxlist"
element.

Please, make a part of your HTML code here.

Best, Ed.

Satheesh Babu B wrote:
hai..
am having a checkboxlist..now how do i get the value of the checkbox
that is checked in checkboxlist using javascript?
Thanks in advance....
Regards,
Satheesh


Oct 19 '05 #2
Satheesh Babu B wrote:
hai..
am having a checkboxlist..now how do i get the value of the checkbox
that is checked in checkboxlist using javascript?


If you mean a radio set, then you loop through the elements and find out
which one is checked. If you mean which checkbox is checked, it's much
the same - search through the checkboxes looking for the ones that have
been checked.

Just remember that when you reference form controls by name, you may get
a collection (radio buttons should always be a collection but it's not
guaranteed) or a single element

Here's some play code:

<form action="">
<div>
<input type="radio" name="rs1" value="zero" checked>zero
<input type="radio" name="rs1" value="one">one
<input type="radio" name="rs1" value="two">two
<br>
<input type="checkbox" name="cb1" value="cb 1">cb 1
<input type="checkbox" name="cb2" value="cb 2">cb 2
<input type="checkbox" name="cb3" value="cb 3">cb 3
<br>
<input type="button" value="Show checked radio value" onclick="
alert(showRadioChecked(this.form.rs1));
"><br>
<input type="button" value="Show all checked values" onclick="
alert(showAllChecked(this.form));
"><br>
<input type="reset">
</div>
</form>

<script type="text/javascript">

function showRadioChecked(rSet)
{
var i = rSet.length;
while(i--){
if (rSet[i].checked) return rSet[i].value;
}
}

function showAllChecked(f)
{
var el, els = f.elements;
var x = '';
var i = els.length;
while(i--){
el = els[i];
if (el.checked){
x += '\n' + el.type + ': ' + el.value;
}
}
return x;
}
</script>

--
Rob
Oct 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Itai | last post by:
I am attempting to create an ASP.NET Custom Validator javascript for a checkboxlist control. My goal is to limit the total number of selections to be 1 - 5 at most. My problem is that I get a null...
0
by: Bryce Budd | last post by:
Hello All, I've been a taker of information from newsgroups for a long time and thought I'd finally make a contribution back to the community whose supported me when I've needed it. After all...
3
by: Robin Day | last post by:
I run some code on the changed event of checkbox lists. Its quite simple, nothing more than showing / hiding some other parts of the page. Using Autopostback and Server side code works fine, but is...
4
by: Shaul Feldman | last post by:
Hello, I have something really awkward at work - fighting with CheckBoxList... How can I define CSS for ListItem in CheckBoxList programmatically. I add CheckBoxList's Items on the fly, something...
1
by: Ryan Scully | last post by:
Hello I have problem with determining exactly what CheckBoxList element is selected using JavaScript code. When I databind to the checkboxlist it renders it on the page and instead of giving each...
3
by: Roy | last post by:
The title is self-explanatory, but I'll show you all what I've done thus far. Here's the aspx side of things(trimmed, of course): <form name="form1" id="Form1" method="post" runat="server">...
14
by: Satheesh Babu B | last post by:
hai.. am having a checkboxlist..now how do i get the value of the checkbox that is checked in checkboxlist using javascript? Thanks in advance.... Regards,
2
by: Stimp | last post by:
I have a checkboxlist (chkMyList) which is created from a (name, value) pair from a database table. I have a read-only textbox which will be used to hold a total of all the numerical values of...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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...
1
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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.