View Full Version : Hyperlink Question

05-18-2009, 09:22 PM
I was using a submit button to call a php function to delete an image file, I want to change it to a hyperlink, just can't get the hyperlink to call the function, I'm doing something wrong. Any help is appreciated. Papajo

<form name='form1' action='/Sizer/A_Image.php' method='post'>

Button Example:<input type='submit' name='submit2' Value='Delete Image'>

Hyperlink Example:<a href='javascript:submit2();'><span>Delete Image</span></a>

$file_delete = "picture2.jpg";
if (unlink($file_delete)) {
echo "<font color=blue><b>The file was deleted successfully</b></font>";
} else {
echo "<font color=red><b>The specified file could not be deleted. Please try again.</b></font>","";

05-18-2009, 09:48 PM
You don't have good Javascript syntax there. You have to call the submit method for the form. document.form1.submit();

You should also Google "unobtrusive javascript" to find out how to best code these kinds of things.