end if end if %> <%=message%>
* Indicates Required

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. [quote] > > 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("newStdUserName")&"','"&Session( > "New StdPassword")&"',"&Request.form("stdAge")&")" > set objCmd.ActiveConnection = Conn > objCmd.CommandText = Query1 > objCmd.CommandType = adCmdText > 'execute the command > objCmd.Execute > response.write "" & "Student details > have > been saved!" > else > response.write "" & "A student by the > same > username exists! Please create another username." > end if > 'response.write session("newStdName") "ID is: " > else > %> > ><% > Response.Redirect("createStudUser.asp") > End If > end if > 'close and dereference database objects > set objCmd = nothing > conn.close > set conn = nothing > > %> > > > > > > > >[/quote] -- Adrienne Boswell Please respond to the group so others can share [url]http://www.arbpen.com[/url] [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => Adrienne [ip] => arbpen@sbcgloba [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 2 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) --> alert or message box? - ASP

alert or message box? - ASP

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 ...

  1. #1

    Default 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>


    monika Guest

  2. #2

    Default Re: alert or message box?

    Gazing into my crystal ball I observed "monika" <monikadanghotmail.com>
    writing in news:emkdRyxgDHA.2188TK2MSFTNGP10.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
    [url]http://www.arbpen.com[/url]
    Adrienne Guest

  3. #3

    Default Re: alert or message box?

    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" <monikadanghotmail.com> wrote in message
    news:emkdRyxgDHA.2188TK2MSFTNGP10.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>
    >
    >

    Tim Guest

Similar Threads

  1. Replies: 7
    Last Post: May 2nd, 02:54 AM
  2. How To Supress Acrobat Error Message And Alert Message
    By ckpang@adobeforums.com in forum Adobe Acrobat SDK
    Replies: 10
    Last Post: January 15th, 11:33 AM
  3. Javascript alert message problem
    By Tony Girgenti in forum ASP.NET Building Controls
    Replies: 19
    Last Post: October 16th, 09:11 PM
  4. warning message (alert)
    By kt03 in forum Coldfusion - Getting Started
    Replies: 2
    Last Post: April 14th, 08:32 PM
  5. Regarding to alert message
    By satishsrs in forum Macromedia Flex General Discussion
    Replies: 1
    Last Post: March 2nd, 09:42 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •