...

View Full Version : Hyperlink Question



Papajo
05-18-2009, 08:22 PM
Hi
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>









if(isset($_POST['submit2'])){
$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>","";
}
}

Fumigator
05-18-2009, 08: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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum