Forums
This topic is locked
conditional region in vbscript
Posted 23 Aug 2002 21:02:24
1
has voted
23 Aug 2002 21:02:24 Dave Clarke posted:
hi im trying to convert my site from javascript to vbscript and i have a problem with a conditional region.this javascript in old site works
<% if (Recordset1.Fields.Item("fldGroup"


<img name="adminbut" border="0" src="graphics/admin.gif" width="108" height="28">
<% } // if (Recordset1.Fields.Item("fldGroup"


and this in vbscript doesnt . . any ideas
<% If rsetAllmembers.Fields.Item("fldGroup"


<img name="adminbut" border="0" src="graphics/admin.gif" width="108" height="28">
<% End If ' end If rsetAllmembers.Fields.Item("fldGroup"


Replies
Replied 24 Aug 2002 07:58:37
24 Aug 2002 07:58:37 Dave Clarke replied:
could the problem above be to do with case sensitivity in the "username" form field in the log-in behaviour??
I have just tried a show region if session("MM_Username"
exists and get an error if the fldusername in the table is David and i log in as david, so i was wondering if Session("MM_UserAuthorization"
is not being set because of the David/david thing,but then again if case sensitivity is an issue why is it letting me log on in either yet not finding the value for MM_UserAuthorization??
I have just tried a show region if session("MM_Username"


Replied 24 Aug 2002 08:03:37
24 Aug 2002 08:03:37 aegis kleais replied:
Don't place the comment on the same line as the END IF
Try :
<%
If (rsetAllmembers.Fields.Item("fldGroup"
.Value = Session("MM_UserAuthorization"
) Then
%>
<img name="adminbut" border="0" src="graphics/admin.gif" width="108" height="28">
<%
End If
' end If rsetAllmembers.Fields.Item("fldGroup"
.Value = (Session("MM_UserAuthorization"
)
%>
Aegis Kleais
New Media Web Developer
(DWMX : IIS5.1 : SQL2K : WXP : ASP[VB/JS])
Try :
<%
If (rsetAllmembers.Fields.Item("fldGroup"


%>
<img name="adminbut" border="0" src="graphics/admin.gif" width="108" height="28">
<%
End If
' end If rsetAllmembers.Fields.Item("fldGroup"


%>
Aegis Kleais
New Media Web Developer
(DWMX : IIS5.1 : SQL2K : WXP : ASP[VB/JS])
Replied 24 Aug 2002 08:22:48
24 Aug 2002 08:22:48 Dave Clarke replied:
thanks aegiskleais but still doesn't work, the button still doesn't show up.
Replied 24 Aug 2002 16:01:36
24 Aug 2002 16:01:36 Dave Clarke replied:
this is just me rambling .. but
the code is checking if ("fldGroup"
.Value is equal to session("MM_UserAuthorization"
.. yes? but the recordset contains details of all members so how does it know which members record it is checking against?
could this be the problem? or on a different vein could it be because ("fldGroup"
is a numerical field?
i am just rambling here but you dont know till you ask<img src=../images/dmxzone/forum/icon_smile_big.gif border=0 align=middle>
anyway for now i'm going with this
If Session(MM_UserAuthorization"
="Admin" Then . . . . .
the code is checking if ("fldGroup"


could this be the problem? or on a different vein could it be because ("fldGroup"

i am just rambling here but you dont know till you ask<img src=../images/dmxzone/forum/icon_smile_big.gif border=0 align=middle>
anyway for now i'm going with this
If Session(MM_UserAuthorization"

Replied 24 Aug 2002 18:54:17
24 Aug 2002 18:54:17 aegis kleais replied:
Well, I'm not even sure what the cross check is supposed to do (no info on that was given)
However if you want, you can force a convert string (this depending too on DB Data Type) like the following:
IF CStr(Recordset1.Fields.Item("fldGroup"
.Value) = CStr(Session("MM_UserAuthorization"
) THEN
That way, if any are numerical, it'll take the string equivalent of it when doing the comparison. I assume here that fldGroup is the group they belong to ("Member", "Admin", etc), and each page uses the above code to determine their access level? You may also want to test if they have Sessions disabled on their end by explicitly setting a Session Variable and then reading it the next line after.
For the time being, remove the comment entirely. When you get the script to work, place it back in and see if it breaks it again.
Otherwise, give us some info on what it is you're doing and what the data is.
Aegis Kleais
New Media Web Developer
(DWMX : IIS5.1 : SQL2K : WXP : ASP[VB/JS])
However if you want, you can force a convert string (this depending too on DB Data Type) like the following:
IF CStr(Recordset1.Fields.Item("fldGroup"


That way, if any are numerical, it'll take the string equivalent of it when doing the comparison. I assume here that fldGroup is the group they belong to ("Member", "Admin", etc), and each page uses the above code to determine their access level? You may also want to test if they have Sessions disabled on their end by explicitly setting a Session Variable and then reading it the next line after.
For the time being, remove the comment entirely. When you get the script to work, place it back in and see if it breaks it again.
Otherwise, give us some info on what it is you're doing and what the data is.
Aegis Kleais
New Media Web Developer
(DWMX : IIS5.1 : SQL2K : WXP : ASP[VB/JS])
Replied 24 Aug 2002 19:21:06
24 Aug 2002 19:21:06 Dave Clarke replied:
ooops silly me
the check is to see if the user who has logged in has a fldGroup value of 1, (which is Admin) and if he does then display a button linking to the admin pages.
If he doesn't then the button is not displayed.
I have the login behaviour set to Username, Password & Access Level.
the check is to see if the user who has logged in has a fldGroup value of 1, (which is Admin) and if he does then display a button linking to the admin pages.
If he doesn't then the button is not displayed.
I have the login behaviour set to Username, Password & Access Level.
Replied 26 Aug 2002 05:35:01
26 Aug 2002 05:35:01 aegis kleais replied:
This may be me, but wouldn't it just have been easier to use "Admin" "Moderator" and what not rather than a series of numbers for the fldGroup?
Aegis Kleais
New Media Web Developer
(DWMX : IIS5.1 : SQL2K : WXP : ASP[VB/JS])
Aegis Kleais
New Media Web Developer
(DWMX : IIS5.1 : SQL2K : WXP : ASP[VB/JS])
Replied 27 Aug 2002 17:18:34
27 Aug 2002 17:18:34 Dave Clarke replied:
I could have used anything really, it was just that the numbers sprang to mind, but it really shouldnt make any difference to how it works should it?
Replied 28 Aug 2002 07:56:32
28 Aug 2002 07:56:32 Dave Clarke replied:
well what do you know, changed them to "Admin" etc and it works fine, weird.
still stranger things happen at sea<img src=../images/dmxzone/forum/icon_smile_big.gif border=0 align=middle>
thanks aegiskleais
still stranger things happen at sea<img src=../images/dmxzone/forum/icon_smile_big.gif border=0 align=middle>
thanks aegiskleais