Hello again! I’m having problems with a SELECT CASE statement group that I’m using to validate a group of forms.
I have 1 page that has 7 forms on it, and each of them call the same subroutine to validate the data entered. There is a CASE statement for each form on the page that contains the validation info for that form. All of that works just how I want it to.
However, the final form on the page is just a submit button, but it is being used to submit the entire page. This means it has to ensure the data in the 6 other forms is validated before it submits. What I’ve done is nested another SELECT CASE group within the CASE statement for that form that recursively calls the function for each of the other 6 forms.
Here’s the code (simplified – only 3 CASE statements) to help you make more sense of what I’m saying:
function Validate_Form(formname)
select case true
case formname=”Define”
if len(frmPHRDefine.define.value)=0 then
Validate_Form = false
else
Validate_Form = true
end if
case formname=”Measure”
if len(frmPHRMeasure.Measure.value)=0 then
Validate_Form = false
else
Validate_Form = true
end if
case formname=”SubmitAll”
select case true
case not Validate_Form(“Define”)
Validate_Form = false
case not Validate_Form(“Measure”)
Validate_Form = false
case else
Validate_Form = true
end select
end select
end function
The problem arises in the ELSE case of the final SELECT CASE group (formname=”SubmitAll”). For some reason, I never get a TRUE result returned for Validate_Form(“SubmitAll”).
I know that the SubmitAll CASE is being called, and I know that the CASE statements within the SubmitAll CASE are working correctly and are called, but when the ELSE case should be executed, I don’t get TRUE returned.
My submit button for the final form looks like this:
<form name=”SubmitAllForm” id=”SubmitAllForm” method=”post” action=”submit.asp”>
<input type=”button” onClick=”if Validate_Form(‘SubmitAll’) then SubmitAllForm.submit() end if”>
</form>
Any ideas? I use the same SUBMIT onClick code for all the other forms on the page and they submit correctly, but just not this one.
I know this is a long-winded description, but I’m trying hard to make sure I explain my problem as well as I can. Thanks in advance!
TBor