PDA

View Full Version : Checkbox and delete confirmation function -HELP


ClueLess
11-07-2002, 11:04 PM
I have a very small delete function.
What I want is: when users check on the checkbox, then a confirmation message popup which is “are you sure you want to delete this record.” if users hit OK, the popup box is gone and keeping the checkbox. If users hit Cancel, then the checkbox is gone and at the same time the checkbox is empty. How am I going to make the CHECKBOX empty when users hit Cancel?
Thanks for your help. VBScript or JavaScript is fine.

Below is my not working code:

<html>
<head>
<title>Untitled</title>
</head>
<script language="javascript">
function handelDelete() {
var agree = false;
agree = confirm('Are you sure you want to delete this record?');
// if (agree) {
// var form = document.forms[0];
// var remove = 0;
// }else {
// return false;
// form.submit();
//}
}

</script>

<body>

<form action="VehicleEdit.asp" method="post" name="SubmitForm" onsubmit="ShowAmendmentDate()">
<table border='0'>
<tr>
<td width="40" align="right" class="regularParagraph">
<INPUT type="checkbox" value='Delete' id='delete' name='delete' onClick='handelDelete();'>
</td>
<td class="regularParagraph" width="250">
<font color="red"><em><b>Please Check before Delete</b></em></font>
</td>
</tr>
<tr>
<td>
<input type="submit" value="Update" name="Delete" class="ActionButton">&nbsp;&nbsp;&nbsp;
</td>
</tr>
</table>
</form>
</body>
</html>

boywonder
11-08-2002, 01:49 AM
Hi,
I'm not sure that I understood your question... does this do what you want?

<html>
<head>
<title>Untitled</title>
</head>
<script language="javascript">
function handelDelete(el) {
el.checked=(confirm('Are you sure you want to delete this record?'));
}
</script>
<body>
<form action="VehicleEdit.asp" method="post" name="SubmitForm" onsubmit="ShowAmendmentDate()">
<table border='0'>
<tr>
<td width="40" align="right" class="regularParagraph">
<INPUT type="checkbox" value='Delete' id='delete' name='delete' onClick='handelDelete(this);'>
</td>
<td class="regularParagraph" width="250">
<font color="red"><em><b>Please Check before Delete</b></em></font>
</td>
</tr>
<tr>
<td>
<input type="submit" value="Update" name="Delete" class="ActionButton">
</td>
</tr>
</table>
</form>
</body>
</html>

ClueLess
11-08-2002, 02:11 PM
:thumbsup:
Thanks, that is what I am looking for.