This topic is locked

Alert/Confirm Dialog

3/6/2009 9:10:38 AM
ASPRunnerPro General questions
A
andie.caron author

Good day to all.
I've searched in this forum but am having no luck, most likely a result of my ineptatude in searching.
What I'd like to do is this:

  1. When a user clicks on Save/Edit button, have a confirmation dialog popup and depending on OK/Cancel committ or cancel,
  2. Popup an alert, for example when a user logins in, on the fourth attempt I redirect them to a page indicating failure. I'd actually like to popup a message indicating an error after 3 attempts.
    I hope this isn't asking too much as I'm new.
    Andie.

A
andie.caron author 3/6/2009

Here is some additional information:
myfunction.asp (included in dbcommon.asp)

<!-- Confirm Action takes an Input string, and confirms users choice -->

<script language="vbscript">
function ConfirmAction(txtAction,txtPrompt)

ConfirmAction = msgBox (txtAction & txtPrompt, vbYesNo)

</script>

In the After Successful Login Event I have this code

set rs = dal.Clients.Query("Login_ID='" & username & "' and Acct_PSWD='" & password & "'","")
' If account in NOT activated, confirm sending to Edit Account Page

if rs("Activated") <> True then

txtMsg = "You need to update your profile to use this system." & vbCRLF

txtMsg = txtMsg & "If you cancel, you will be sent back to the Login Page." & vbCRLF

if ConfirmAction(txtMsg,"Continue Y/N") then

redir = "Clients_edit.asp?editid1=" & rs("ACCT_NO")

else

redir = "login.asp"

end if

%>
<script type='text/javascript'>

location.href = '<% = redir %>';

</script>
<%

response.end

end if

No error is generated, and the user is directed to the menu, not to the appropriate edit page.
If I do this:

if rs("Activated") <> True then

response.redirect("Clients_edit.asp?editid1=" & rs("ACCT_NO"))

end if

The user is directed to the appropriate edit page. So I'm hoping someone can see where my code is gone goofy.
rs("ACCT_NO") is a valid number (in my test case it equals 1167), so that is not the problem (as I verified with the last piece of code).
I know the function works as I've used it in other asp projects with home spun code.
I really need to get this working.
Thanks everyone.
Andie
ps: I check to see if rs("Activated") <> TRUE to make sure I have a valid condition. It makes no difference if I compare it to 0 (ZERO).

E
ErinSigma 3/6/2009

Hi Andie, try this (place directly after your last strMSG assigment):
redir = "TABLENAME_edit.asp?editid1=" & rs("AccountNo") - or whatever MasterKey you use...

rs.Close

Set rs = Nothing

%>
<script type='text/javascript'>

alert('<% = strMSG %>');

location.href = '<% = redir %>';

</script>
<%

response.end

end if
This is the code I use and it works just fine. I also tried to use a Function that we've had in place for other projects, but just couldn't get it to kick in.
Hope this helps

A
andie.caron author 3/6/2009

Perfect, thank you it works like a charm.