Monika
|
Posted: 01/13/2002, 12:15 AM |
|
I want to display a popup message when someone clicks submit? I don't want to give a choice, just some information and an 'OK' button. For instance, 'Thanks for submitting this. It will be reviewed and added shortly.'
I am Using ASP .
When I use the following javascript code In the 'Before Insert' or 'After Insert' event in CC
<script Language="JavaScript" >
alert("'Thanks for submitting this. It will be reviewed and added shortly.");
</script>
OR - the following script suggested by "Nickita"
<SCRIPT Language="JavaScript">
if (document.forms["FormName"])
document.FormName.onsubmit=insertmes;
function insertmes() {
if (document.FormName.FormAction.value == 'insert')
alert(' your message');
}
</SCRIPT>
gives me the following error message :
Microsoft VBScript compilation error '800a0400'
Expected statement
/monika/Complaint_entry.asp, line 200
<script Language="JavaScript" >
How Can I solve this?
Monika
|
|
|
Ken Hardwick
|
Posted: 01/13/2002, 8:37 AM |
|
Somewhere in this form, I found the following...for confirming delete..
(I would give that person credit but am having trouble finding his/her post)
Add the following function to global functions..and then add
CreateConfirm("formname") to your PAGE-Close event...
Now, that will get you a delete confirm...see further down for suggestion
to do a message with "Insert" as you are requesting...
Sub CreateConfirm(formName)
if IsEmpty(formName) Then
Response.Write("<code>Attempt to call CreateConfim without a form name!</code>")
Exit Sub
End If
Response.Write( "<SCRIPT Language='JavaScript'>")
Response.Write( "if (document.forms['" & formName & "'])" )
Response.Write( "document." & formName & ".onsubmit=delconf;" )
Response.Write( "function delconf() {" )
Response.Write( "if (document." & formName & ".FormAction.value == 'delete')" )
Response.Write( "return confirm('Are you sure you want to delete this record? The delete cannot be undone!'); ")
Response.Write( "}")
Response.Write( "</SCRIPT>")
End Sub
******************************************************************************
Add the following function to global functions
and add
CreateConfirmInsert("formname")
(with the appropriate formname) to your page close event.
Note the changes to function..changed delete to insert on the action type.
Change name of "on submit" function
Changed message type from "confirm" that prompts for "OK" or "Cancel"
to "Alert" that prompts for "OK" only.
Sub CreateConfirmInsert(formName)
if IsEmpty(formName) Then
Response.Write("<code>Attempt to call CreateConfim without a form name!</code>")
Exit Sub
End If
Response.Write( "<SCRIPT Language='JavaScript'>")
Response.Write( "if (document.forms['" & formName & "'])" )
Response.Write( "document." & formName & ".onsubmit=insertconf;" )
Response.Write( "function insertconf() {" )
Response.Write( "if (document." & formName & ".FormAction.value == 'insert')" )
Response.Write( "return alert('Thanks for submitting this. It will be reviewed and added shortly.'); ")
Response.Write( "}")
Response.Write( "</SCRIPT>")
End Sub
Ken Hardwick
ken@KenHardwick.com
www.kenhardwick.com
Norman,Ok
|
|
|
Ken Hardwick
|
Posted: 01/13/2002, 10:23 AM |
|
The function I was referring to was in the "Tips and Article"
Adding JavaScript Confirm Delete Dialog to ASP Pages
By dean
see..http://www.gotocode.com/art.asp?art_id=78&
...Thanks Dean !
Ken Hardwick
|
|
|
Nicole
|
Posted: 01/14/2002, 2:51 AM |
|
Monica,
you should add the code provided by Nickita to Record form->Footer section not to any page events. Don't forget to replace "FormName" with the real name of the record form.
Events are used for custom ASP code that is executed on server side. JavaScript code is executed on client side that's why you cannot mix them.
|
|
|
Madnest
|
Posted: 05/16/2002, 11:40 AM |
|
Where is this close event he is talking about?
i have a record named dlc_employes1 for deletion but i cant figure out in which event i must put the CreateConfirm("formname")
Thanks
|
|
|