469,313 Members | 2,316 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,313 developers. It's quick & easy.

CheckBox

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

May 24 '07 #1
5 3867
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Fabri | last post: by
reply views Thread by mike | last post: by
2 posts views Thread by bebop | last post: by
5 posts views Thread by DotNetJunkies User | last post: by
2 posts views Thread by Adam Knight | last post: by
2 posts views Thread by Ceema M via DotNetMonster.com | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.