This topic is locked

How to use confirm in events

3/26/2016 10:45:24 AM
ASPRunnerPro General questions
N
nbwenren author

When I add or modify a record, if the inspection of a specific record, if there is a record of the specific records, deleted it, before deleting need to pop up the confirmation window, how to achieve in the events, thanks!

begin of my code:

'删除完全重叠的记录

set Rs1 = Server.CreateObject("Adodb.RecordSet")

sql="select * from TABLE_RESUME where C_EMP_ID = '" & cid & "' and C_ENDDATE <= '" & endda & "' and C_BEGDATE > '" & begda & "'"

dbConnection.Execute sql

Rs1.open sql,dbConnection,1,1

if not Rs1.eof or not Rs1.bof then

Response.Write("<script language='javascript'>var i=confirm('" & begda & "'至'" & endda & "'期间的'" & Rs1.RecordCount & "'条记录将被删除?');</script>")

' Response.Write("<script language='javascript'>if(confirm('确认删除记录吗?')){i=1;return i;}else{history.back();return false;}</script>")

if i=true then

if message <> "" then

brstr="<BR>"

else

brstr=""

end if

message = message & brstr & "<font color = red>'" & begda & "'至'" & endda & "'期间的'" & Rs1.RecordCount & "'条记录被删除!</font>"

sql="delete from TABLE_RESUME where C_EMP_ID = '" & cid & "' and C_ENDDATE <= '" & endda & "' and C_BEGDATE > '" & begda & "'"

dbConnection.Execute sql

end if

' date1=Rs1("C_ENDDATE")

' message = "<font color = red>结束日期为'" & endda & "'的" & Rs1.RecordCount & "条记录被定界!</font>"

end if

Rs1.close

end of my code

Actual operation, will not pop up the confirmation window.

admin 3/27/2016

It just doesn't work this way. Events are executed on the web server and you cannot ask for confirmation from server side event.
Take a look at this article that explains how to achieve this:

https://xlinesoft.com/asprunnerpro/docs/how_to_ask_for_confirmation_before_saving_record.htm

N
nbwenren author 3/27/2016



It just doesn't work this way. Events are executed on the web server and you cannot ask for confirmation from server side event.
Take a look at this article that explains how to achieve this:

https://xlinesoft.com/asprunnerpro/docs/how_to_ask_for_confirmation_before_saving_record.htm



Thank you for answer so quickly.The members of xlinesoft are great! <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=79092&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' /> <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=79092&image=2&table=forumreplies' class='bbc_emoticon' alt=':)' />

I hope when a User add or edit a record, check exsist data in sql server before save.If exsist specific record ask for confirmation.When the user select button true delete the specific record.Also save the record of add or edit in the same time.If select cancel button doesn't executed delete and save.Can the article you gived be able to achieve this problom? Thank you very much agan!

My English is poor. Can you see the problom what I saied?

admin 3/29/2016

This is going to be more complicated than that. Since you are limited to Javascript any sort of operations that require database access need to be executed via AJAX. You need to execute an AJAX request to custom ASP file that performs calculations, get response back and either proceed with saving the record or ask user for confirmation.
You can see an example of similar technique in this article (though this is for PHP):

http://www.asprunner.com/forums/topic/22701-custom-dependent-dropdown-boxes/

N
nbwenren author 3/30/2016



This is going to be more complicated than that. Since you are limited to Javascript any sort of operations that require database access need to be executed via AJAX. You need to execute an AJAX request to custom ASP file that performs calculations, get response back and either proceed with saving the record or ask user for confirmation.
You can see an example of similar technique in this article (though this is for PHP):

http://www.asprunner.com/forums/topic/22701-custom-dependent-dropdown-boxes/



Thank you very much for your answers. I will try to follow the way you provide, if I have any questions I will ask you again. Thank you again!
Best regards,

nbwenren