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.
> 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.