473,387 Members | 1,700 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,387 software developers and data experts.

one checkbox selection

I have 3 checkboxes but the user should select just one.
How to block multiple checkbox selection ?

Joja
Dec 26 '06 #1
1 1774
Joja wrote:
I have 3 checkboxes but the user should select just one.
How to block multiple checkbox selection ?
<form>
<input type="checkbox" name="C1" value="1" onClick="only1(this.name)">
<input type="checkbox" name="C2" value="2" onClick="only1(this.name)">
<input type="checkbox" name="C3" value="3" onClick="only1(this.name)">
</form>
<script type="text/javascript">
var checkelements = new Array("C1","C2","C3")
function only1(which)
{
for(var i=0; i<checkelements.length; ++i) {
if (document.forms[0].elements[checkelements[i]].name != which)
document.forms[0].elements[checkelements[i]].checked = false;
}
}
</script>

I'm not sure why you don't want

<input type="radio" name="R" value="1">
<input type="radio" name="R" value="2">
<input type="radio" name="R" value="3">

Hope this helps,

--
Bart

Dec 26 '06 #2

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

Similar topics

0
by: claudel | last post by:
Hi I have a newb PHP/Javascript question regarding checkbox processing I'm not sure which area it falls into so I crossposted to comp.lang.php and comp.lang.javascript. I'm trying to...
1
by: thejackofall | last post by:
Hi. I have a checkbox column in my datagrid like this: <Columns> <asp:TemplateColumn HeaderText=" "> <ItemTemplate> <asp:CheckBox ID='Selection' runat="server"></asp:CheckBox> <asp:Label...
4
by: Nicolas Rubin | last post by:
Hi, I would transfer the result of a checkbox selection into an SQL request. Could you help me ? Many thanks in advance Nicolas
2
by: Andre Ranieri | last post by:
Hi folks, I have a datagrid which contains a template item checkbox column. I've included a checkbox as a HeaderTemplate item which fires a server-side function to check or uncheck all the...
1
by: puja | last post by:
hi all, I have a form which has checkbox list which has items as below 1) Input 1 2) Input 2 3) Input 3 4) Input 4 5) Input 5
3
by: =?Utf-8?B?QmFkaXM=?= | last post by:
Hi, I have a 5 checkboxes and I would like to be able to use them as grouped radiobuttons or a checkboxlist (one selection at the time) in the client side without having to use a autopostback....
3
by: delram | last post by:
I'm trying to get user selections (using checkboxes) on one JSP page(A.jsp) and pass them on to another page. So I have one page with a list of dynamically populated items like this 1 2 ...
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...
3
by: uremog | last post by:
I have a set of of check boxes. onClick, the checkboxes call check_radio and recup_checkbox. the referenced radios function as group selectors. check_radio just unchecks the radios if someone...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.