MAIN MENU
Using a Javascript alert message in ASP
ASP scripts often have logic where you wish to test for some condition, such as if a record set is empty, and then display a message indicating that no records exists. The message could be displayed on an html page, but a neater method is to create a Javascript pop up alert and then use history.go to take the display back.
<%
if objRs.RecordCount = 0 then
%>
<script language="javascript">
<!--
window.alert ("display message");
window.history.go(-1);
//-->
</script>
<%
Response.End
else
...do something else...
end if
%>
if objRs.RecordCount = 0 then
%>
<script language="javascript">
<!--
window.alert ("display message");
window.history.go(-1);
//-->
</script>
<%
Response.End
else
...do something else...
end if
%>