473,466 Members | 1,565 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

CheckBox

HI
how to select only one check box in two checkboxes like radio buttons

May 24 '07 #1
5 3962
On May 24, 10:27 am, java.i...@gmail.com wrote:
HI

how to select only one check box in two checkboxes like radio buttons
Take a book on Javascript and English language, syntax and grammar,
then try it again and if you don't succeed, then come back here and
ask the question again, but with more details on what your problem is
(not only what you want to do even if you haven't tried it yourself)

May 24 '07 #2
Darko wrote on 24 mei 2007 in comp.lang.javascript:
On May 24, 10:27 am, java.i...@gmail.com wrote:
>>
how to select only one check box in two checkboxes like radio buttons

Take a book on Javascript and English language, syntax and grammar,
then try it again and if you don't succeed, then come back here and
ask the question again, but with more details on what your problem is
(not only what you want to do even if you haven't tried it yourself)
The OP could be right:

That one in two checkboxes do like radio buttons.

Don't you love them?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
May 24 '07 #3
On May 24, 12:56 pm, "Evertjan." <exjxw.hannivo...@interxnl.net>
wrote:
Darko wrote on 24 mei 2007 in comp.lang.javascript:
On May 24, 10:27 am, java.i...@gmail.com wrote:
how to select only one check box in two checkboxes like radio buttons
Take a book on Javascript and English language, syntax and grammar,
then try it again and if you don't succeed, then come back here and
ask the question again, but with more details on what your problem is
(not only what you want to do even if you haven't tried it yourself)

The OP could be right:

That one in two checkboxes do like radio buttons.

Don't you love them?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
HTML
<input type="checkbox" name="test" id="test" value="1"
onclick="check_it(this);" />
<input type="checkbox" name="test" id="test1" value="2"
onclick="check_it(this);" />

SCRIPT
function check_it(obj)
{
if (this.id == 'test' && this.checked) {
document.getElementById('test1').checked = false;
}
elseif (this.id == 'test1' && this.checked) {
document.getElementById('test').checked = false;
}
}

This is just a very simple way to do it.

May 24 '07 #4
Jeff Johns wrote:
HTML
<input type="checkbox" name="test" id="test" value="1"
onclick="check_it(this);" />
<input type="checkbox" name="test" id="test1" value="2"
onclick="check_it(this);" />

SCRIPT
function check_it(obj)
{
if (this.id == 'test' && this.checked) {
document.getElementById('test1').checked = false;
}
elseif (this.id == 'test1' && this.checked) {
document.getElementById('test').checked = false;
}
}

This is just a very simple way to do it.
Too bad it doesn't work as is.

All instances of "this" in your "SCRIPT" block should be "obj".

Also, there is no such thing as an "elseif" in JavaScript. You meant
"else if".

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
May 24 '07 #5
On May 24, 5:43 pm, -Lost <maventheextrawo...@techie.comwrote:
Jeff Johns wrote:
HTML
<input type="checkbox" name="test" id="test" value="1"
onclick="check_it(this);" />
<input type="checkbox" name="test" id="test1" value="2"
onclick="check_it(this);" />
SCRIPT
function check_it(obj)
{
if (this.id == 'test' && this.checked) {
document.getElementById('test1').checked = false;
}
elseif (this.id == 'test1' && this.checked) {
document.getElementById('test').checked = false;
}
}
This is just a very simple way to do it.

Too bad it doesn't work as is.

All instances of "this" in your "SCRIPT" block should be "obj".

Also, there is no such thing as an "elseif" in JavaScript. You meant
"else if".

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
Indeed, sorry for the confusion.

Here this works:

SCRIPT
function check_it(obj)
{
if (obj.id == 'test' && obj.checked) {
document.getElementById('test1').checked = false;
}
else if (obj.id == 'test1' && obj.checked) {
document.getElementById('test').checked = false;
}

}

May 25 '07 #6

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

Similar topics

4
by: Fabri | last post by:
How can I, on button click, to select ONLY the following 4 checkbox? I would like to do this without a for loop through form.lenght because this is only an example and I have to apply this script...
4
by: feanor | last post by:
I need to select children checkboxes when selecting the parent one. This is my function: function SelectChildrens(checkbox_name){ form = document.forms; Sname = checkbox_name.split("-"); for...
0
by: mike | last post by:
Hi there: I've read an excellent "how to"-article by Microsoft (no. 306227) - partly cited cited at the end of this email). I have implemented the code related to the part "How to Add a...
2
by: bebop | last post by:
I'm using three checkbox web controls in C# .NET and one button, and one labe Is there a way to "group" these individual checkbox web controls If so, do I use a for loop, hashtable, array,...
5
by: DotNetJunkies User | last post by:
1. i want to populate checkboxlist using javascript only at client side ....how can i do this..by populate word i mean that checkboxes should be checked or unchecked on some condition basis.......
2
by: Adam Knight | last post by:
Hi all, I have a datagrid with a checkbox in one column. The checkbox is set to autopostback and calls a method named UpdateMailSubscribers. The first click on the checkbox cause the page to...
2
by: Ceema M via DotNetMonster.com | last post by:
Hello all, I have a nested repeater, which displays categories(parent repeater) and corresponding subcategories(child repeater). Both repeaters have checkboxes. When I check category checkbox...
4
by: Wolfgang Uhr | last post by:
Hello I've the following code Panel pnlData = new System.Windows.Forms.Panel(); CheckBox checkBox = new System.Windows.Forms.CheckBox(); checkBox.AutoSize = true; checkBox.Dock =...
10
by: rn5a | last post by:
All the rows in a DataGrid, including the Header, are accompanied with a CheckBox. I want that when the CheckBox in the Header is checked, then all the CheckBoxes should automatically get checked....
0
by: cyberdawg999 | last post by:
Greetings all in ASP land I have overcome one obstacle that took me 2 weeks to overcome and I did it!!!!! I am so elated!! thank you to all who invested their time and energy towards helping me...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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
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?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.