473,463 Members | 1,527 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How do I check for multple selection of CHECKBOX?

Hi everyone

I wrote an application that generates HTML based on some database
record set. One of the HTML generated is a checkbox with
NAME=StudentID. This is to facilitate user to select this user for
further processing. This also means that ALL student have a checkbox
named StudentID. I do I ensure that only one checkbox is selected at
any time before the user proceed with the processing of the selected
student.
Jul 23 '05 #1
2 1405
"Fendi Baba" <ef*****@epitome.com.sg> wrote in message
news:c9**************************@posting.google.c om...
Hi everyone

I wrote an application that generates HTML based on some database
record set. One of the HTML generated is a checkbox with
NAME=StudentID. This is to facilitate user to select this user for
further processing. This also means that ALL student have a checkbox
named StudentID. I do I ensure that only one checkbox is selected at
any time before the user proceed with the processing of the selected
student.


Will this help? Watch for word-wrap.

<html>
<head>
<title>boxcheck.htm</title>
<script type="text/javascript">
function boxcheck() {
var boxs = 0;
var form = document.forms[0];
for (var i=0; i<form.elements.length; i++) {
if (form.elements[i].type == "checkbox") {
if (form.elements[i].checked) boxs++;
}
}
if (boxs != 1) alert("Check one and only one box.");
}
</script>
</head>
<body>
<form action="" method="get">
<input type="checkbox" name="StudentID" value="1">
<input type="checkbox" name="StudentID" value="2">
<input type="checkbox" name="StudentID" value="3">
<input type="button" value="Click" onclick="boxcheck()">
<input type="reset" value="Clear">
</form>
</body>
</html>
Jul 23 '05 #2
Fendi Baba wrote:
I do I ensure that only one checkbox is selected at
any time before the user proceed with the processing of the selected
student.


Why don't you use radio buttons for that purpose instead? No
client-side scripting would be involved (only server side validation
would still be necessary), and they are designed, so that only one radio
button per group can be selected.

--
Lachlan Hunt
http://lachy.id.au/
http://GetFirefox.com/ Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox
Jul 23 '05 #3

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

Similar topics

1
by: Raghuram Banda | last post by:
Hi there, I'm new programmer in JavaScript. Can any one help in creating a checkbox (by default selected) from JavaScript and creating Drop down box (<select> ... </select>) from Javascript. ...
8
by: lawrence | last post by:
I'm a beginner with Javascript and especially cross-browser Javascript. I got this working in IE, but not in Netscape 7. It seems like, in Netscape, every time I click on a button, the focus shifts...
5
by: A.Dagostino | last post by:
hi i need to update an SQL Table when user select or unselect a checkbox control. How Can i do? Thanks Alex
1
by: Steven Stewart | last post by:
Hi there, I have a form with a bound text box control and a frame with two unbound check boxes. When the user checks one of the check boxes, the bound text box control is set to a certain value...
1
by: .NETn00b | last post by:
Is this possible? I need to create a multi-select DataGrid, and I cannot use CheckBoxes. I want the selected rows to appear highlighted. One possible work-around that occurred to me was to...
1
by: scprosportsman | last post by:
Please help guys, i am trying to set up a database here at work and im fairly new to access in terms of writing functions and queries and stuff. I have 2 different places on my design that will...
0
by: New2ASP | last post by:
Thanks everyone in advance for your help. I am fairly new to web development but an experienced window-based developer. Here's the structure of my Gridview Column 1 : Checkbox with SelectAll...
1
by: rjoseph | last post by:
HI Guys I have a simple check box form (using GET as the method) with a list of 10 different UK counties. I have validated the form so that users have to select no more and no less than 5 UK...
5
by: Andrew Meador | last post by:
I have a form (Change Card List by Status) with a check box (cboNOT) and a list box (lstStatus). There is an Open Report button that opens a report (Report - Change Card List) which uses a query...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.