Ok, I got my form working and all is good with the world, well - sort of. I need to test to make sure that at least one of the 18 check boxes is "checked" before the form will submit. The input fields are named "c1" through "c18". I need a javascript function that will allow me to check all of the boxes for the status of "checked". If so, then the form can submit. If not, an alert pops up requesting at least one box be checked.
my code so far:
---------------
<script language="javascript">
<!--//
var arybox = new Array();
i=0
while (i<=18){
arybox = ""
i++
}
function getspecs(box,num,fld){
if (box.checked == true){
var spec = fld + ": " + prompt("Please specify the size(s) you would like to receive:",arybox[num]);
arybox[num] = spec;
}
}
function submitspecs(){
var specval = ""
i=0
while (i<=18){
if(arybox != ""{
specval = specval + i + "," + arybox + "\n";
}
i++
}
document.samples.specs.value = specval;
//alert(specval)
}
function submitform(){
if (document.samples.name.value.length <= 0){
alert("Please enter your name.\n"
document.samples.name.focus();
return false;
}
if (document.samples.address.value.length <= 0){
alert("Please enter your address.\n"
document.samples.address.focus();
return false;
}
if (document.samples.city.value.length <= 0){
alert("Please enter your city.\n"
document.samples.city.focus();
return false;
}
if (document.samples.state.value.length <= 0){
alert("Please enter your state.\n"
document.samples.state.focus();
return false;
}
if (document.samples.zip.value.length < 4){
alert("Please enter your zipcode.\n"
document.samples.zip.focus();
return false;
}
if (document.samples.company.value.length <= 0){
alert("Please enter your company name.\n"
document.samples.company.focus();
return false;
}
if (document.samples.phone.value.length <= 0){
alert("Please enter your phone number.\n"
document.samples.phone.focus();
return false;
}
if (document.samples.email.value.length <= 0){
alert("Please enter your email.\n"
document.samples.email.focus();
return false;
}
submitspecs();
document.samples.submit();
return true;
}
//-->
</script>
my code so far:
---------------
<script language="javascript">
<!--//
var arybox = new Array();
i=0
while (i<=18){
arybox = ""
i++
}
function getspecs(box,num,fld){
if (box.checked == true){
var spec = fld + ": " + prompt("Please specify the size(s) you would like to receive:",arybox[num]);
arybox[num] = spec;
}
}
function submitspecs(){
var specval = ""
i=0
while (i<=18){
if(arybox != ""{
specval = specval + i + "," + arybox + "\n";
}
i++
}
document.samples.specs.value = specval;
//alert(specval)
}
function submitform(){
if (document.samples.name.value.length <= 0){
alert("Please enter your name.\n"
document.samples.name.focus();
return false;
}
if (document.samples.address.value.length <= 0){
alert("Please enter your address.\n"
document.samples.address.focus();
return false;
}
if (document.samples.city.value.length <= 0){
alert("Please enter your city.\n"
document.samples.city.focus();
return false;
}
if (document.samples.state.value.length <= 0){
alert("Please enter your state.\n"
document.samples.state.focus();
return false;
}
if (document.samples.zip.value.length < 4){
alert("Please enter your zipcode.\n"
document.samples.zip.focus();
return false;
}
if (document.samples.company.value.length <= 0){
alert("Please enter your company name.\n"
document.samples.company.focus();
return false;
}
if (document.samples.phone.value.length <= 0){
alert("Please enter your phone number.\n"
document.samples.phone.focus();
return false;
}
if (document.samples.email.value.length <= 0){
alert("Please enter your email.\n"
document.samples.email.focus();
return false;
}
submitspecs();
document.samples.submit();
return true;
}
//-->
</script>