Forum Moderators: open

Message Too Old, No Replies

limit to if... elseif ...?

im probobly justmissing something..

         

natty

12:10 pm on Mar 16, 2005 (gmt 0)

10+ Year Member



hi all,

having a bit of problem with an elseif snippet..
to explain a little. the checkboxes that have been submitted are all names chkCODE] where theCODE is in the format of one of the re's below SV01AE for instance, SV02AE etc (i also know that the ones that are failing are in the form and checked)
i am building up the strings to pass to a searchy stored procedure.
i admit it may have been easier to name all the groups the same thing and suck it all into an array, but as i MUST assign labels to each checkbox, the names HAVE to be different so no easy option as far as i can see. but then i usually am looking in the wrong places :)


'set up the re's
Set oRE_AE = New RegExp
oRE_AE.Pattern = "SV\d+AE"
Set oRE_AS = New RegExp
oRE_AS.Pattern = "SV\d+AS"
Set oRE_SS = New RegExp
oRE_SS.Pattern = "SV\d+SS"
Set oRE_RE = New RegExp
oRE_AE.Pattern = "PE\d+RE"
Set oRE_AT = New RegExp
oRE_AT.Pattern = "PE\d+AT"
'lets get looping
for each checkbox in Request.Form
if inStr(checkbox, "chk") = 1 then
'this is a checkbox
theCode = right(checkbox, (len(checkbox)-3))
showtext "testing : " & theCode & "<br />"
if oRE_AE.Test(theCode) = true then
strAccomEmergency = strAccomEmergency & theCode & ","
elseif oRE_AT.Test(theCode) = true then
strAcceptOrTarget = strAcceptOrTarget & theCode & ","
elseif oRE_AS.Test(theCode) = true then
strAccomSpecialist = strAccomSpecialist & theCode & ","
elseif oRE_SS.Test(theCode) = true then
strAccomSecondStage = strAccomSecondStage & theCode & ","
elseif oRE_RE.Test(theCode) = true then
strSelfReferrals = strSelfReferrals & theCode & ","
end if
end if
next

it never ever hits the last elseif for some reason.. if i were to swap the bottom one with the top, then the new bottom elseif would never hit.
im sure im missing something, and i cant be casing as far as i can see.

any ideas?

tia

nat

CaseyRyan

3:46 pm on Mar 16, 2005 (gmt 0)

10+ Year Member



In your code, you're not giving a value to oRE_RE. You're setting oRE_RE to a new RegExp, then you're setting the value for oRE_AE. Happens to me all the time when I write something once and copy/paste it to save time.

Set oRE_RE = New RegExp
oRE_AE.Pattern = "PE\d+RE"

-=casey=-