473,395 Members | 1,368 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

alert or message box?

I am not clear ... whether to use alert of JavaScript or messagebox of
VBScript in ASP. But what I want is that when a user has some error I want
to display a pop-up kind of a thing saying "you have not entered all the
values" ... and when he click "ok" then he should be directed to the same
page where he was entering the values. I tried this but in my case I am just
being redirected to the page ..and my message box in not being popped up!

here is my code:
<%
DIM RSA
DIM QUERY1
DIM RSA2
DIM QUERY2
DIM Conn
dim adCmdText
dim stAge

session("newStdId") = Request.form("stdID")
session("newStdName") = Request.form("stdName")
session("newStdUserName") = Request.form("stdUserName")
session("newStdPassword") = Request.form("stdPassword")
session("newStdAge") = Request.form("stdAge")

StAge = Request.form("stdAge")
adCmdText = 1
'create and open database connection
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "dsn=school"

'create commad object
set objCmd = server.createobject("adodb.command")

If Request.form("newStudent") = "Click to save details of new student" then
If Request.form("stdname") <>"" and Request.form("stdUsername") <> "" and
Request.form("stdpassword")<> "" and Request.form("stdAge")<> "" then
Set RSA2 = Server.CreateObject("ADODB.Recordset")
QUERY2 = "SELECT student_name from student_info where
student_username='"&Request.form("stdUsername")&"' "
RSA2.open QUERY2, "dsn=school"
if RSA2.EOF then
QUERY1 = "INSERT INTO student_info (student_name,student_username,
student_password,student_age) VALUES
('"&Session("newStdName")&"','"&Session("newStdUse rName")&"','"&Session("New
StdPassword")&"',"&Request.form("stdAge")&")"
set objCmd.ActiveConnection = Conn
objCmd.CommandText = Query1
objCmd.CommandType = adCmdText
'execute the command
objCmd.Execute
response.write "<font color=#000080 size=6>" & "Student details have
been saved!"
else
response.write "<font color=#000080 size=6>" & "A student by the same
username exists! Please create another username."
end if
'response.write session("newStdName") "ID is: "
else
%>
<SCRIPT language="vbscript">
msgbox("YOUR HAVE NOT ENTERED ALL THE VALUES")
</SCRIPT>
<%
Response.Redirect("createStudUser.asp")
End If
end if
'close and dereference database objects
set objCmd = nothing
conn.close
set conn = nothing

%>
<html>
<head>

<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body BGCOLOR="pink">
</body>
<html>
Jul 19 '05 #1
2 33731
Gazing into my crystal ball I observed "monika" <mo********@hotmail.com>
writing in news:em**************@TK2MSFTNGP10.phx.gbl:
I am not clear ... whether to use alert of JavaScript or messagebox of
VBScript in ASP. But what I want is that when a user has some error I
want to display a pop-up kind of a thing saying "you have not entered
all the values" ... and when he click "ok" then he should be directed
to the same page where he was entering the values. I tried this but in
my case I am just being redirected to the page ..and my message box in
not being popped up!
That's because you're doing something server side that needs to be done
client side.

This is what I do:

Form.asp:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Fill out form</title>
<%
dim required
dim message
dim name
dim email

required = request.querystring("required")
name = request.querystring("name")
email = request.querystring("email")

if required <> "" then
select case required
case "name"
message = "Name is required"
case "email"
message = "Email is required"
end select

if message <> "" then
message = "<div style='font-weight:bold; color:red'>" & message &
"</div>"
<script type="text/javascript">
<!--
alert('<%=message%>');
//-->
</script>
end if
end if
%>
</head>
<body>
<%=message%>
<form id="form" method="post" action="form2.asp">
<fieldset><legend>* Indicates Required</legend>
<label for="name">Name: * </label> <input type="text" name="name"
id="name" value="<%=name%>" /><br />
<label for="email">Email: *</label> <input type="text" name="email"
id="email" value="<%email%>" /><br />
<input type="submit" value="Submit">
</fieldset>
</form>
</body>

On form2.asp -

<% dim name
dim email
dim required

name = request.form("name")
email = request.form("email")

if name = "" then
required = "name"
elseif email = "" then
requried = "email"
end if

if required <> "" then
response.redirect "form.asp?required=" & required & "&name=" & name &
"&email=" & email
response.end
else
'do whatever your script is supposed to do
end if
%>

Obviously you can do a lot more error checking, loop through request
objects, etc.

here is my code:
<%
DIM RSA
DIM QUERY1
DIM RSA2
DIM QUERY2
DIM Conn
dim adCmdText
dim stAge

session("newStdId") = Request.form("stdID")
session("newStdName") = Request.form("stdName")
session("newStdUserName") = Request.form("stdUserName")
session("newStdPassword") = Request.form("stdPassword")
session("newStdAge") = Request.form("stdAge")

StAge = Request.form("stdAge")
adCmdText = 1
'create and open database connection
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "dsn=school"

'create commad object
set objCmd = server.createobject("adodb.command")

If Request.form("newStudent") = "Click to save details of new student"
then
If Request.form("stdname") <>"" and Request.form("stdUsername") <> ""
and
Request.form("stdpassword")<> "" and Request.form("stdAge")<> "" then
Set RSA2 = Server.CreateObject("ADODB.Recordset")
QUERY2 = "SELECT student_name from student_info where
student_username='"&Request.form("stdUsername")&"' "
RSA2.open QUERY2, "dsn=school"
if RSA2.EOF then
QUERY1 = "INSERT INTO student_info (student_name,student_username,
student_password,student_age) VALUES
('"&Session("newStdName")&"','"&Session("newStdUse rName")&"','"&Session(
"New StdPassword")&"',"&Request.form("stdAge")&")"
set objCmd.ActiveConnection = Conn
objCmd.CommandText = Query1
objCmd.CommandType = adCmdText
'execute the command
objCmd.Execute
response.write "<font color=#000080 size=6>" & "Student details
have
been saved!"
else
response.write "<font color=#000080 size=6>" & "A student by the
same
username exists! Please create another username."
end if
'response.write session("newStdName") "ID is: "
else
%>
<SCRIPT language="vbscript">
msgbox("YOUR HAVE NOT ENTERED ALL THE VALUES")
</SCRIPT>
<%
Response.Redirect("createStudUser.asp")
End If
end if
'close and dereference database objects
set objCmd = nothing
conn.close
set conn = nothing

%>
<html>
<head>

<link rel="stylesheet" href="style.css" type="text/css" /> </head>
<body BGCOLOR="pink"> </body> <html>


--
Adrienne Boswell
Please respond to the group so others can share
http://www.arbpen.com
Jul 19 '05 #2
Tim
if it is in the asp code, it will run on the server and the client wont see
it.

if it is in the html code that is sent to the client, then 'msgbox' will
only run on IE, 'alert' will run on anything.
Tim
"monika" <mo********@hotmail.com> wrote in message
news:em**************@TK2MSFTNGP10.phx.gbl...
I am not clear ... whether to use alert of JavaScript or messagebox of
VBScript in ASP. But what I want is that when a user has some error I want
to display a pop-up kind of a thing saying "you have not entered all the
values" ... and when he click "ok" then he should be directed to the same
page where he was entering the values. I tried this but in my case I am just being redirected to the page ..and my message box in not being popped up!

here is my code:
<%
DIM RSA
DIM QUERY1
DIM RSA2
DIM QUERY2
DIM Conn
dim adCmdText
dim stAge

session("newStdId") = Request.form("stdID")
session("newStdName") = Request.form("stdName")
session("newStdUserName") = Request.form("stdUserName")
session("newStdPassword") = Request.form("stdPassword")
session("newStdAge") = Request.form("stdAge")

StAge = Request.form("stdAge")
adCmdText = 1
'create and open database connection
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "dsn=school"

'create commad object
set objCmd = server.createobject("adodb.command")

If Request.form("newStudent") = "Click to save details of new student" then If Request.form("stdname") <>"" and Request.form("stdUsername") <> "" and
Request.form("stdpassword")<> "" and Request.form("stdAge")<> "" then
Set RSA2 = Server.CreateObject("ADODB.Recordset")
QUERY2 = "SELECT student_name from student_info where
student_username='"&Request.form("stdUsername")&"' "
RSA2.open QUERY2, "dsn=school"
if RSA2.EOF then
QUERY1 = "INSERT INTO student_info (student_name,student_username,
student_password,student_age) VALUES
('"&Session("newStdName")&"','"&Session("newStdUse rName")&"','"&Session("New StdPassword")&"',"&Request.form("stdAge")&")"
set objCmd.ActiveConnection = Conn
objCmd.CommandText = Query1
objCmd.CommandType = adCmdText
'execute the command
objCmd.Execute
response.write "<font color=#000080 size=6>" & "Student details have
been saved!"
else
response.write "<font color=#000080 size=6>" & "A student by the same username exists! Please create another username."
end if
'response.write session("newStdName") "ID is: "
else
%>
<SCRIPT language="vbscript">
msgbox("YOUR HAVE NOT ENTERED ALL THE VALUES")
</SCRIPT>
<%
Response.Redirect("createStudUser.asp")
End If
end if
'close and dereference database objects
set objCmd = nothing
conn.close
set conn = nothing

%>
<html>
<head>

<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body BGCOLOR="pink">
</body>
<html>

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: iceking | last post by:
Hi, I have a php script that checks whether the user is allowed to perform an action. If he is not allowed; I display a warning; using the alert function. After clicking away this function, I want...
1
by: Ali | last post by:
Hello! I am trying make a alert message in an asp.net application, but i ned that the button tha appear into the message change the languaje depending the user. Anybody know hoe i can do that? ...
1
by: Vivian | last post by:
I've created a web page with ASP .NET and C#. Say my aspx filename is "WebForm1.aspx", I have created another C# file named "Details.cs". My problem is I want to prompt an alert message from both...
22
by: Tony Girgenti | last post by:
Hello. I'm developing and testing a web application using VS.NET 2003, VB, .NET Framework 1.1.4322, ASP.NET 1.1.4322 and IIS5.1 on a WIN XP Pro, SP2 computer. I'm using a web form. Using...
3
by: Wayne Deleersnyder | last post by:
Hi All, I'm trying to create a function that will cause a pop-up alert to appear if dates which were chosen from a drop-down list were invalid on a page. There's 4 dates, so there's the...
15
by: cyberlei | last post by:
Hey guys, i was trying to use alert message for php string,but dunno why the alert can`t be displayed, so please help me where i did wrong, THANKS SO MUCH here is the code: <SCRIPT...
5
by: cyberlei | last post by:
Hey Guys, Just wandering if I can display alert message with a default sound. the current code is below and the problem is no sounds. function disp_alert() { alert("test") } and...
3
by: nagmvs | last post by:
Hai guys, I want the the code to disable Left Mouse button with out Alert message. Below code i am having <!-- This code is for disableing left click--> <script language="javascript">...
2
by: shrinivas singh | last post by:
If I remove alert messsage,it works fine.But, with alert message nothing is displayed after alert message but the blank screen.Below is the code: <iframe width = "100%" height = "1100" src =...
0
by: Anupam Jana | last post by:
Hello All, I want to redirect to some other directory page after displaying JavaScript alert message in ASP.net in a page. For that I tried bellow code in our application...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.