Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dynamic if then 2

Status
Not open for further replies.

sharedworld

Programmer
Dec 25, 2003
65
US
I need to generate on my asp page a dynamic if then, which means, that i have some updatables values on my database, i wan't open my database take the values and make something like this:

do while not rs.eof then
if vIf="" then
vIf="if instr(rs(""criteria""),rs("brand"))"
else
vIf=vIf & " and instr(rs(""criteria""),rs("brand"))"
end if
loop

if vIf<>&quot;&quot; then
vIf=vIf & vbcrlf & &quot; then&quot;
vIf=vIf & &quot;response.write &quot;&quot;blabla&quot;&quot;&quot;
vIf=vIf & vbCrlf & &quot;End if&quot;
execute vIf
end if

something like this, is this possible?...
 
mmmmm, to me this looks like setting a flag/ semaphore:


dim lCriteriaMet
lCriteriaMet = false
do while not rs.eof then
if instr(rs(&quot;&quot;criteria&quot;&quot;),rs(&quot;brand&quot;)) <> 0 then
lCriteriaMet = true
end if
rs.movenext
loop

if lCriteriaMet then
response.write &quot;&quot;blabla&quot;&quot;
end if






br
Gerard
 
Well, you could make a boolean variable to hold the result from all the records, something like:
Code:
Dim bIf
bIf = True   'default it to true so as not to negate effect of later And's
Do While Not rs.eof then
   bIf = bIf And (InStr(rs(&quot;criteria&quot;),rs(&quot;brand&quot;)) > 0)
   rs.MoveNext
Loop

If bIf = True Then
   Response.Write &quot;whatever&quot;
End If

I think this may be closer to what you were looking for, ie, an And check for each record all combined into a single boolean If Then.

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
thank you guys, I gonna check it... but looks good...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top