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

need to popup a message box from server side script 1

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
I want to pop up a message box from within server side scripting
Code:
<% @language="vbscript" %>

<SCRIPT LANGUAGE="VBScript">
sub PopupBox(Title,Msg)
	msgbox(msg, vbOKOnly, Title)
End sub
</SCRIPT>

<%
' how do I call the sub PopupBox from here
%>

DougP, MCP, A+
 
not sure..but any ways did you mean this:

Code:
<% @language="vbscript" %>

<SCRIPT LANGUAGE="VBScript">
sub PopupBox(Title,Msg)
    PopupBox=MsgBox(msg, vbOKOnly, Title)
End sub
</SCRIPT>

<%
response.write "Test page" & "<br>"
%>
<script>
PopupBox "blah", "just testing"
</script>
<%
response.write "end"
%>


Also use javascript instead of vbscript...

-DNG
 
The server doesn't do anything to the browser except respond to browser requests.

The response might be a script that the browser interprets as a command to show an alert or confirmation... but that is really the choice of the browser as to wheter to actually obey the command. If JavaScript is disabled then the browser will ignore the command or, if you write the script in VBScript then some browsers might not even attempt to run it.
 
DotNetGnat
Ok that works great

How do I refresh the page so it reloads.
this does not work
<script>
PopupBox "blah", "just testing"
</script>
<% response.redirect "samepagename.asp"%>

I see your point Sheco
I am going to be the only one using this page and it works in my browser IE6 with the current settings.

DougP, MCP, A+
 
after you click ok on the msgbox...any code after the script resumes...so your redirect works after clicking ok in the msg box...

-DNG
 
it does nothing
the code you helped me with happens after the page is posted to
If UCase(Request.ServerVariables("HTTP_METHOD")) = "POST" Then
<SCRIPT>
PopupBox "User Already Exists","Please key in another user"
</SCRIPT>
<%
response.redirect "add_logon.asp"
%>
<%else%>
‘show the form
<form name="myForm" action="<%=ADD_LOGON%>" method="POST">

</form>
<%end if%>

Nothing shows up I guess because it’s still in POST mode. Is there a way to make it not in POST mode?
The only way I know how to do this is close the browser and rekey in the page so it loads new, clicking refresh on the browser does not work either. I'm not sure I understand how pages work I came from VB6 and VBA.


DougP, MCP, A+
 
Ok now it passes by the popup altogether and just refreshes the page
Argh!!!
if I rem out
response.redirect it pops up the message box and leaves the page blank
if I put it back it ignores the popup and refreshes the page
So the server side script over rides the client side?
Or


DougP, MCP, A+
 
So the server side script over rides the client side?
yes. you are right.

-DNG
 
So how do I pop up a message box "AND" refresh the page?

DougP, MCP, A+
 
here is the thing...server side script executes first and then the client side script is executed.

so for the task you are trying to accomplish...you need to do a redirect with in the client side script...

-DNG
 
Ok how do I do that?
I've not used vbscript in a while so I don't remember
also I'm used to VB6 with tons of help and tons of syntax checking and intellisense so on.
I'm lost here


DougP, MCP, A+
 
here is the sample:

Code:
<html>
<head>
<script language="javascript">
alert ("Testing")
window.location = "add_logon.asp"
</script>
</head>

<body>
</body>
</html>

-DNG
 
I would prefer vbscript
but thank you anyway for all your time and help

DougP, MCP, A+
 
here you go:

Code:
<html>
<head>
<script language="vbscript">
msg ("Testing")
window.location.href = "add_logon.asp"
</script>
</head>

<body>
</body>
</html>

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top