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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

session variable

Status
Not open for further replies.

lucyc

Programmer
Mar 1, 2002
62
US
Does anyone know how to pass a session variable to sub??? I created a session variable called sGroup. When I did the response.write, I can see the value, but I can't get the value when I did the msgbox "sgroup: " & sGroup. in the btnclient_onClick . Here is my code :
<html>
<%
sGroup=Session(&quot;sGroup&quot;)
Response.Write sGroup
%>

<SCRIPT LANGUAGE=VBScript>

Sub btnclient_OnClick()
msgbox &quot;sgroup: &quot; & sGroup '***getting nothing here??????
If sGroup=&quot;MH&quot; then
document.url = &quot;url&quot;
Else
document.url = &quot;url&quot;
End If
End Sub
</script

Thanks in advance.
 
try this
<html>
<%
sGroup=Session(&quot;sGroup&quot;)
Response.Write sGroup
%>

<SCRIPT LANGUAGE=VBScript>

Sub btnclient_OnClick()
dim sgroup
sgroup = &quot;<%=Session(&quot;sGroup&quot;)%>&quot;
msgbox &quot;sgroup: &quot; & sGroup
If sGroup=&quot;MH&quot; then
document.url = &quot;url&quot;
Else
document.url = &quot;url&quot;
End If
End Sub
</script
[bomb]
I may not get it the 1st or 2nd time,
but how sweet that 15th time can be.
admin@onpntwebdesigns.com
 
Hello onpnt,

Thanks for your help. It works. Thank you very much.
 
hi, how would you do that the other way eg:
//your current code
<SCRIPT LANGUAGE=VBScript>
dim sgroup
sgroup = &quot;hello&quot;
sgroup = &quot;<%=Session(&quot;sGroup&quot;)%>&quot;
</script>

//what i want to do (set the session var in VBScript
<SCRIPT LANGUAGE=VBScript>
dim sgroup
sgroup = &quot;hello&quot;
&quot;<%=Session(&quot;sGroup&quot;)%>&quot; = sgroup
</script>

thanks in advance
Darren

####################
# #
# Darren@DGoulston.com #
###################
 
<%
Session(&quot;sGroup&quot;)=&quot;Hello&quot;
%>

Hope This Help
PH.
 
but i need to do it in the VBScript section cause i have a varible that i want to go into the session one.

####################
# #
# Darren@DGoulston.com #
###################
 
Do a keyword search in this forum about variable.
Anyway, the Session object is Server side

Hope This Help
PH.
 
I need to do the same thing with that....load a value from a form into a session variable when a button is clicked...but since the button clicking code is client-side and ASP is server side...is there a way to do it? Surely there must be.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top