Calling Javascript Confirm from ASP Classic/VBScript

I am attempting to call a confirm popup from asp classic. Is there a way I can get this Javascript code to execute? It is currently not being called/executed. I need a popup to appear allowing the user to confirm if they want to clear an assignment or not. Thanks!

<%@ Language=VBScript %>
<!--#include file="content/securityheader.asp"-->
<!--#include file="connection.inc"-->
<!--#include file="connectionxref.inc"-->
<!--#include file="securityheader.asp"-->
<!--#include file="connectionSQL.inc"-->

<% 'SQL SECURITY CODE
    function dbencodeStr(str)
        thestr = trim(replace(str,"'","&#39;"))
        thestr = trim(replace(thestr,"""","&#34;"))
        thestr = trim(replace(thestr,"<","&lt;"))
        thestr = trim(replace(thestr,">","&gt;"))
        thestr = trim(replace(thestr,vbCRLF,"<BR>"))
        dbencodeStr = thestr
    end function
%>
<script language = "javascript"  runat="server">
function clearAssignment(assignmentID,relno,docrecid)
{
if (confirm("This is the last assignment for this relationship.")){
    window.location.assign("procclearassignmentprompt.asp?assignmentID="+assignmentID+"&relno="+relno+"&docrecid="+docrecid);
    }
}
</script>
<%
Server.ScriptTimeout=3600

'------------------------------
Function getName(str)
index = instr(str," ")
if index > 0 then
str = trim(mid(str,1,index))
end if
getName = str
End Function
'------------------------------

on error resume next

assignmentID = dbencodeStr(request.Querystring("assignmentID"))
docid = dbencodeStr(request.Querystring("docrecid"))
relno = dbencodeStr(request.Querystring("relno"))
thedate = now()

count = 1
'Check if this is the last assignment for relationship
strSQL = "select count(distinct reldocassignments.id) from reldocnotes inner join reldocassignments on reldocnotes.docid=reldocassignments.docid where relno = '"&relno&"' and reldocassignments.activeflag=1"
Set rs = objConnection.Execute(strSQL, ,adCmdText)
    arr = rs.GetRows()
    rows = UBound(arr,2)
    for i = 0 to rows       
        count = trim(arr(0,i))
    next
if count = 1 then
Response.Write "Calling =" & clearAssignment(assignmentID,relno,docrecid) & "."
else
    if docid <> "" Then
        ''''Close any open assignments for the document
        strSQL = "update RelDocAssignments set activeflag = 0, closedOn = getdate() where docid = '"&docid&"' and ID = '"&assignmentID&"';"
        Set rs = objConnection.Execute(strSQL, ,adCmdText)
    end if
Response.write(strSQL)


''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''

objConnection.close
set objConnection = nothing
objConnection2.close
set objConnection2 = nothing
objConnection3.close
set objConnection3 = nothing

Response.Redirect "relDetails.asp?relNo=" & relno
end if

%>
Count = <%=count%>

Open in new window

Jordan JohnsonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
<script language = "javascript"  runat="server">
function clearAssignment(assignmentID,relno,docrecid)
{
if (confirm("This is the last assignment for this relationship.")){
    window.location.assign("procclearassignmentprompt.asp?assignmentID="+assignmentID+"&relno="+relno+"&docrecid="+docrecid);
    }
}
</script>
That function definition is code meant to be executed on the client/browser side, not the server.  So you have to get rid of runat="server"

>> I need a popup to appear
At what point in time? Upon load?  Try changing:
Response.Write "Calling =" & clearAssignment(assignmentID,relno,docrecid) & "."

to:
Response.Write "clearAssignment(" & assignmentID & "," & relno & "," & docrecid &");"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
You can't use the confirm function on the server side, you would need to use it client side before submitting the form
0
Ryan ChongCommented:
so always split your presentation (confirmation) and processing logic (Update SQL statement) into different layers (pages) so you would have a clearer way to manage your scripts, and that will mitigate any potential risks of mess up your application.

the confirmation can be done either at client side or server side but they will have different approaches to do it.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.