On Q_28290100 I saw a number of solutions for checking if a value exists in a comma delimited list, but I was wondering if it possible to check if '1' is contained in the string AND if '2' is NOT contained in the string.
What would that syntax look like in this statement if we were to modify it?
<%test="1,3,7,9,10" if checkIT(test,"1","2") then%><div class="nav">Nav bar</div><%end if%><%' functions are typically at the top or bottom of your page.function checkIT(user_type,valueToCheckInclude, valueToCheckExclude) checkInclude=false checkExclude=true arrUsertype=split(user_type,",") for each number in arrUsertype if cstr(number)=cstr(valueToCheckInclude) then checkInclude=true end if if cstr(number)=cstr(valueToCheckExclude) then checkExclude=false end if next if checkInclude = true And checkExclude = true then checkIT = true else checkIT = false End ifend function%>
But here's the issue - I have about 20 buttons with about 6 possible conditions. Like one button might be for 1, 3, and 7s, and another button is for 1,2 and 7. Another is 2 and 5 only.
Building the array seems like a thorough thing to do, but would lead to a huge amount of additional lines of code, compared with something smaller like the original solution. I mean, am I close with this approach?
<% if (instr(Session("UserType"),"1") or NOT instr(Session("UserType"),"2") then %>
then a separate function makes even more sense:
Open in new window