J
java.inet
HI
how to select only one check box in two checkboxes like radio buttons
how to select only one check box in two checkboxes like radio buttons
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)
Darko wrote on 24 mei 2007 in comp.lang.javascript:
The OP could be right:
That one in two checkboxes do like radio buttons.
Don't you love them?
Jeff said: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".
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.