sara
|
| Posted: 05/07/2002, 12:04 PM |
|
hii,
i need a before delete event that shows a pop window to aske the user if he are sure he want to selete when he press ok the code charge will delete
|
|
|
 |
Andrew B
|
| Posted: 05/07/2002, 1:18 PM |
|
Place the following block of javascript in the footer of your form, or of the page. Modify it to use the name of the form you want to confirm delete on. So, change the '<FormName>' to the name of your form 'EditPerson', and change every other reference to <FormName> to your form's name as well. If you are not sure, look at the HTML and see what the form's 'name' property is.
This code also confirms on 'update' and sets a hidden form variable to '1' so that in the 'on update' code I know to make a backup of the information. You proabably don't need this part
As soon as the page loads, the first block of javascript checks to make sure the form exists, and if it does it binds the form's 'onsubmit' action to the function below. This is equiv. to writing 'onsubmit="javascript:ConfirmActions;"' in the <form> tag itself.
<SCRIPT Language="JavaScript">
if (document.forms['<FormName>']) {
document.<FormName>.onsubmit=ConfirmActions;
}
function ConfirmActions() {
var f;
f = document.<FormName>;
'--- onDelete - Asks if the user is sure ---------------
if (f.FormAction.value == 'delete') {
return confirm('Are you sure you want to delete?');
}
//--- OnUpdate - Asks if a backup is desired -----------
if (f.FormAction.value == 'update') {
var ret;
ret = confirm('Do you want to save a backup?');
if (ret == true) {
f.Archive.value = 1;
}
}
}
</SCRIPT>
If you need more help, post again.
|
|
|
 |
*sara
|
| Posted: 05/09/2002, 4:35 AM |
|
wooow thanks Andrew B the code is great
|
|
|
 |
|