/    Sign up×
Community /Pin to ProfileBookmark

Problem with CASE statement

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

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliJun 06.2003 — Its too confusing at least for me..:-)

Post a link to your page,there might be a way simple way of getting this all done..
Copy linkTweet thisAlerts:
@TBorauthorJun 10.2003 — AAAAARRRRGGGGG!!!!

Thanks Dave! I couldn't figure out why the code wouldn't work as written.... that is, until I found a typo in a form field name! Thanks for taking the time to run that code, as I was still convinced it was the structure, not the spelling.

Shaking his head in disgust/thanks,

TBor
×

Success!

Help @TBor spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...