
Originally Posted by
Ayomide
Am I understanding you correctly, the javascript, which is client-side, needs to be place on the page that is calling the SQL delete code?
It would need to placed on the form or button that is used to initiate the deletion. For example:
Code:
function confirmDeletion() {
return confirm('Are you sure want to delete this employee record?');
}
HTML Code:
<input type="submit" name="operation" value="Delete"
onclick="return confirmDeletion();">
If this is valid, then I have a greater challegne in calling two functions on the sending page that using the forms tag.
If you mean you have a function that is already called during submission (say, a validation function) then this fairly trivial to accomodate.
If the existing function is just 'some function' that doesn't affect whether the form is sent, then just place a semicolon after the first function call:
HTML Code:
<form action="..." method="..."
onsubmit="originalFunction(); return confirmDeletion();">
If the existing function is a validation function, or something similar, then you can combine the return value with the confirmation function using the logical AND (&&) operator:
HTML Code:
<form action="..." method="..."
onsubmit="return originalFunction() && confirmDeletion();">
Addititionally, I would like to reflect within the confirm message box the value the user entered in the specific text box.
That too is quite simple. Assuming the text box is named employeeID, then you could change the above to:
Code:
function confirmDeletion(message) {
return confirm(message
+ '\nAre you sure want to delete this employee record?');
}
HTML Code:
<form action="..." method="..."
onsubmit="return originalFunction()
&& confirmDeletion('Employee ID: ' + this.elements.employeeID.value);">
Mike
Bookmarks