Reputation: 8528
I am having trouble to put the right attribute in a action
on <form>
in HTML
I plan to create a DELETE button which on clicking would prompt a alert box for confirmation.
Upon receiving the right input would delete that entry.
URL for deleting the file is given by "deleteFile?ID=$file_name"
Here is what I have developed so far:
<form METHOD="LINK" action="deleteFile?ID=$fileID"
<input TYPE="submit" VALUE="Delete">
</form>
</td>
Can you please help for prompting for the alert box. I have written the code in JavaScript called COnfirmDelete()
I am not able to put all the pieces together like :
Upvotes: 2
Views: 3712
Reputation: 3931
Sample
http://jsfiddle.net/Xv2V4/2/
It is better not to have script in html script
tags, but JSfiddle won't recognize my functions defined below.
JS
function ConfirmDelete() {
/* if you need to check this ID or sth. else. */
var fileId = document.getElementById("fileId");
var user_confirm = confirm('Really delete this file?');
/* Check your file ID or whatever you want to check here. */
return user_confirm;
}
HTML
<form method="GET" action="deleteFile" onsubmit="return ConfirmDelete();">
<!-- print $fileID with python to have it in HTML -->
<input type="hidden" id="fileId" name="ID" value="$fileID" />
<input type="submit" value="Delete" />
</form>
Upvotes: 1