Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2004
    Posts
    75

    Question Unanswered: Not sure what to call it

    How do you get the message box or whatever it is call to popup? You know like if you are closing a page and the yes/no pops up. what is that called and what would the code be to make one come up?

    This is an error code I would like to have it pop for:

    re.Pattern = "^\d{3}-\d{3}-\d{4}$"
    errorArray(2) = re.Test(phone_number)
    if errorArray(2) then
    errorArray(2) = False
    else
    errorArray(2) = True
    ErrorMsg = ErrorMsg & "Telephone Number<br>"
    end if

    breeze76
    Last edited by breeze76; 05-04-04 at 10:14.

  2. #2
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    That would be a modal dialog box...

    Code:
    <%
    re.Pattern = "^\d{3}-\d{3}-\d{4}$"
    errorArray(2) = re.Test(phone_number)
    if errorArray(2) then
      errorArray(2) = False
    else
      errorArray(2) = True
      ErrorMsg = ErrorMsg & "Telephone Number<br>"
    end if
    %>
    <script language="JavaScript">
    <!--
    //Simple "Ok" prompt
    alert("<%=ErrorMsg%>");
    
    //Confirmation Yes/No Prompt
    confirm("<%=ErrorMsg%>");
    
    //Use confirm message in an If statement
    if( confirm("<%=ErrorMsg%>") ){
      //Yes was clicked - do something
    }
    else{
      // No was clicked - do something else
    }
    //-->
    </script>
    Last edited by Seppuku; 05-04-04 at 16:02.
    That which does not kill me postpones the inevitable.

  3. #3
    Join Date
    Apr 2004
    Posts
    75
    Ok I used this one here:

    alert("<%=ErrorMsg%>");

    I works fine but my only problem is that I have four or five errors that can be included at one time. They do not all fit in the message box... how would I code it so that if none of the required fields are entered, up to 4 or 5 they will all show and could be read easily?

    Thanks for the code though, it does do the job.

    breeze76

  4. #4
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    At the end of each message, include a \n. This will put a newline character at the end, and start the next error on the next line.

    Code:
    <%
      Dim ErrorMsg
      ErrorMsg = "1) This is an error message\n\n"
      ErrorMsg = ErrorMsg & "2) A second error message\n\n"
      ErrorMsg = ErrorMsg & "3) A third error message"
    %>
    
    <script language="JavaScript">
    <!--
    alert(<%=ErrorMsg%>);
    //-->
    </script>
    This will make an error box pop up with the message formatted like:
    Code:
     
    1) This is an error message
    
    2) A second error message
    
    3) A third error message
    Or you could get fancy and make an html error popup. This way you can make nicely designed error pages.
    Code:
    <%
      Dim ErrorMsg
      ErrorMsg = "1,2,3"
    %>
    
    <script language="JavaScript">
    <!--
    window.open("errormsg.asp?ErrorMsgID=<%=ErrorMsg%>", "ErrorMsgWin", "height=300,width=300");
    //-->
    </script>
    ErrorMsg.asp:
    Code:
    <html><body>
    <%
      Dim aErrorMsgs()
      Dim aErrorArray
    
      ReDim aErrorMsgs(3)
      aErrorMsgs(0) = "This is message 1."
      aErrorMsgs(1) = "This is message 2."
      aErrorMsgs(2) = "This is message 3."
    
      aErrorArray = Split(Trim(Request.QueryString("ErrorMsgID")), ",")
    
      Dim x
      For x = 0 To UBound(aErrorArray)
        Response.Write aErrorMsgs(aErrorArray(x)) & "<BR>"
      Next
    %>
    </body></html>
    That which does not kill me postpones the inevitable.

Posting Permissions

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