B
barn104_1999
I have a form with 7 drop down boxes, and I need to write a script that
will make sure that at least one is selected.
Here is what I currently have, although I'm a little stumped as to
where to go next (I've only listed the script to one of the dropdowns,
as the rest were commented out anyway). Thanks:
function checkNorman_session_Tuesday_June_6th(choice){
var count1=0;
var error = "";
if (choice ==0){
count1=0;
}else {count1 += 1;
}
return error;
}
function checkClassSession(choice) {
var error = "";
var count_total = count1;
if (count_total == 0) {
error = "Please choose a class session from the drop-down
list.\n\n";
}
if (count_total > 1) {
error = "Please select only one class session from the drop-down
lists.\n\n";
}
return error;
}
<!-- Begin check form script, which refers to "validate.js" code,
listed above -->
<!--
function checkWholeForm(theForm) {
var why = "";
why += checkLastName(theForm.last_name.value);
why += checkFirstName(theForm.first_name.value);
why += checkDepartment(theForm.department.value);
why += checkEmail(theForm.email.value);
why += checkPhone(theForm.phone.value);
/*why += checkClassSession(value);*/
/*why +=
checkNorman_session_Tuesday_June_6th(theForm.Norman_session_Tuesday_June_6th.selectedIndex);*/
/*why += checkClassSession(theForm.class_session.selectedIndex);*/
if (why != "") {
alert(why);
return false;
}
return true;
}
// -->
</script>
will make sure that at least one is selected.
Here is what I currently have, although I'm a little stumped as to
where to go next (I've only listed the script to one of the dropdowns,
as the rest were commented out anyway). Thanks:
function checkNorman_session_Tuesday_June_6th(choice){
var count1=0;
var error = "";
if (choice ==0){
count1=0;
}else {count1 += 1;
}
return error;
}
function checkClassSession(choice) {
var error = "";
var count_total = count1;
if (count_total == 0) {
error = "Please choose a class session from the drop-down
list.\n\n";
}
if (count_total > 1) {
error = "Please select only one class session from the drop-down
lists.\n\n";
}
return error;
}
<!-- Begin check form script, which refers to "validate.js" code,
listed above -->
<!--
function checkWholeForm(theForm) {
var why = "";
why += checkLastName(theForm.last_name.value);
why += checkFirstName(theForm.first_name.value);
why += checkDepartment(theForm.department.value);
why += checkEmail(theForm.email.value);
why += checkPhone(theForm.phone.value);
/*why += checkClassSession(value);*/
/*why +=
checkNorman_session_Tuesday_June_6th(theForm.Norman_session_Tuesday_June_6th.selectedIndex);*/
/*why += checkClassSession(theForm.class_session.selectedIndex);*/
if (why != "") {
alert(why);
return false;
}
return true;
}
// -->
</script>