Putting Session Data In A VBScript

C

Colin Steadman

I'm trying to create a VBScript using ASP. However I'm having
problems getting data from session variables into the right places.
The example I have copied below works, however I need to replace
"data1" and "data2" with real data from a session variable.

However if I replace this:

Call OpenDoc("data1", "data2")

With this:

Call OpenDoc(<%=session("var1")%>, <%=session("var2")%>)

It breaks.


<html>
<head>
<script language=vbscript>
Sub button_onclick()
Call OpenDoc("data1", "data2")
End Sub

Sub OpenDoc(v1, v2)
msgbox v1
msgbox v2
End Sub
</script>
</head>
<body>
<input type=button name=button value="Click">
</body>
</html>

Any ideas?

TIA,

Colin
 
S

Steven Burn

How about;

data1 = session("var1")
data2 = session("var2")

Call OpenDoc("data1", "data2")

or

data1 = Request.Form("var1")
data2 = Request.Form("var2")

Call OpenDoc("data1", "data2")


--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
 
R

Ray at

What "breaks" about it? What shows up in a view-source, as this is a client
side routine you're calling. Are the argument you're passing in there? Are
they string values that need to be in quotes, but are instead being
interpreted as variables, perhaps?

Ray at work
 
E

Evertjan.

Colin Steadman wrote on 21 jan 2004 in
microsoft.public.inetserver.asp.general:
However if I replace this:

Call OpenDoc("data1", "data2")

With this:

Call OpenDoc(<%=session("var1")%>, <%=session("var2")%>)

It breaks.

And it should.
You put strings without "" as parameters for a clientside function call

You will end up with nonsense like:

Call OpenDoc(this is not a string, because it is undelimited)

in stead of:

Call OpenDoc("this is a string", "delimited too")


Try this:

Call OpenDoc("<%=session("var1")%>", "<%=session("var2")%>")

Always view-source your asp output, if such things go wrong.
 
C

Colin Steadman

And it should.
You put strings without "" as parameters for a clientside function call

You will end up with nonsense like:

Call OpenDoc(this is not a string, because it is undelimited)

in stead of:

Call OpenDoc("this is a string", "delimited too")


Try this:

Call OpenDoc("<%=session("var1")%>", "<%=session("var2")%>")

Always view-source your asp output, if such things go wrong.


Bingo!

That was exactly the problem. I made the change you suggested and its
now working as I had originally intended.

That said I've just discovered (by accident) that it worked the other
way too, but only if I passed it a number.


<html>
<head>
<script language=vbscript>
Sub button_onclick()
Call OpenDoc("<%=Session("var1")%>", "<%=Session("var2")%>")
End Sub

Sub OpenDoc(v1, v2)
msgbox v1
msgbox v2
End Sub
</script>
</head>
<body>
<input type=button name=button value="Click">
</body>
</html>


Thanks for tipping me off (+ other_contributors)!

Colin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top