Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checkbox Validation 3

Status
Not open for further replies.

peter11

Instructor
Mar 16, 2001
334
US
I have four check boxes with different names, I want to require that one and only one of them are selected.

Is this possible

I cannot use radio boxes in this situation.


Thanks
 
Yes, it is possible, however, why not radio buttons? They would be the ideal solution.


use the radioBox.checked = true/false to check your boxes "The surest sign that intelligent life exists elsewhere in the universe is that it has never tried to contact us"
Bill Watterson, Calvin & Hobbes
 
How would I create an If stattement, stating that one of the boxes must be selected?

 
something like:

<script>
var names=[
&quot;chbx1&quot;,
&quot;chbx2&quot;,
&quot;chbx3&quot;,
&quot;chbx4&quot;
]
formname=&quot;form1&quot;
var _form

onload=function(){
_form=document.forms[formname]
}

function uncheckAll(){
for(var ii=0; ii<names.length; ii++){
_form[names[ii]].checked=false
}
}

function checkit(_name){
uncheckAll();
_form[_name].checked=true;
}
</script>

..

<form .. name=&quot;form1&quot;>
..
one<input type=&quot;checkbox&quot; name=&quot;chbx1&quot; onclick=&quot;checkit(this.name)&quot; checked>
two<input type=&quot;checkbox&quot; name=&quot;chbx2&quot; onclick=&quot;checkit(this.name)&quot;>
three<input type=&quot;checkbox&quot; name=&quot;chbx3&quot; onclick=&quot;checkit(this.name)&quot;>
four<input type=&quot;checkbox&quot; name=&quot;chbx4&quot; onclick=&quot;checkit(this.name)&quot;>
..
</form> Victor
 
Hi.

I'm just beginner in javascript, so I had and ordinary question, I guess.

There are few photos in the page, one checkbox for each photo. A visitor marks his favorite pics, enters his nickname ant submits. How to make it, that I could get the numbers of pictures and a nickname of a visitor by mail? Is it possible to make only bu javascript, without php, perl adn etc. ?

Thank you.

Blacker
 
Just one note here:

Never use javascript when you can use CGI. 10% of internet viewers have javascript disabled, so always strive to make your sites not need javascript in order to work.

evil popup ads >:-(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top