client side asp within server side asp

J

JT

im trying to use the following code to log whenever a user clicks through
this particlular message box - however, this currently logs regardless of
whether or not the message box was clicked - im assuming this is because the
server-side code can't see the client side if condition. but how can i set
the varMsgBox variable as a server-side variable?

<!--switch to client-side VBScript to use the MsgBox-->
<script language="VBSCRIPT">
dim varMsgBox
varMsgBox = "0"
varMsgBox = MsgBox ("<%=pop_up_text%>", 16, "Urgent Message")
'log that user clicked through the pop-up message - switch back to
server-side to call function to insert log message into the db
if varMsgBox = "1" then
<% Call dumplogfile("User clicked through the pop-up message: " &
pop_up_text)%>
end if
</script>
 
B

Bob Barrows [MVP]

JT said:
im trying to use the following code to log whenever a user clicks
through this particlular message box - however, this currently logs
regardless of whether or not the message box was clicked - im
assuming this is because the server-side code can't see the client
side if condition. but how can i set the varMsgBox variable as a
server-side variable?
You can't. All server-side code runs before client-side code is processed.
 
B

Bob Lehmann

No, because by the time the message box comes up, control has switched to
the client.

Bob Lehmann
 
B

Bob Barrows [MVP]

No, that article talks about what you've successfully done: cause a
client-side action from from server-side code. It's a one-way street. Data
can only be passed to server-side code via the Request object, which only
exists when the page is initially called.

To do what you want will involve another page.

Bob Barrows
 
R

Ray Costanzo [MVP]

1. With your particular example, will the response from your msgbox ever be
anything but 1? You don't leave the user many options when you have only
"vbOK"

2. Since your usage of VBScript in the browser already indicates you are
into doing things in an unorthodox way (said with a "<g>" of course!), you
could do something like so:

yourpage.asp:

<%
Dim pop_up_text
pop_up_text = "All your base are belong to us"
%>
<img id="x" style="display:none;" />

<script type="text/javascript">
//sorry, I cannot bring myself to use vbscript,

if(confirm('<%=pop_up_text%>')) {
var o = document.getElementById('x');
x.src =
'./process.asp?user=IdentifiedSomehow&m=<%=Server.URLEncode(pop_up_text)%>';
}
</script>



process.asp:

<%
Dim sUser, sMessage, oCDO
sUser = Request.Querystring("user")
sMessage = Request.Querystring("m")
Set oCDO = CreateObject("CDO.Message")
oCDO.From = "(e-mail address removed)"
oCDO.To = "(e-mail address removed)"
oCDO.Subject = "User clicked OK"
oCDO.TextBody = sUser & " clicked OK to a prompt of " & sMessage
oCDO.Send
Set oCDO = Nothing
%>




Ray at work
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top