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

CheckBox

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

May 24 '07 #1
5 3956
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: 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: 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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.