Forum Moderators: open
<script language="javascript" type="text/javascript" >
function confirmDelete() {
var confirm = document.getElementById("confirm");
confirm.value = window.confirm("Are you sure you want to delete?");
return confirm.value;
}
</script>
<form enctype="multipart/form-data" action="delPicture.php" method="post" onsubmit="return confirmDelete();">
<div id="Triggered"><b>Delete by Id</b></div>
<input type="hidden" name="confirm" id="confirm" value="false">
<input name="recordId" type="text" value="" /><br>
<input type="submit" value="Delete"/>
</form>
@dolphine
The problem is that this:
return confirm.value;
return (confirm.value == "true");
Apart from it not being good form, are there any problems associated with using confirm as a variable name and a hidden form element name when it's already a built-in function name?
function confirmDelete() {
var c = document.getElementById("confirm");
var bConfirm = confirm("Are you sure you want to delete?");
c.value = bConfirm;
return bConfirm;
}
I agree, it is probably not good form to name your internal variables such that they could conflict with window object methods.
FWIW:
[developer.mozilla.org...]