Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-18-2009, 08:22 PM   PM User | #1
Papajo
New Coder

 
Join Date: Oct 2008
Posts: 28
Thanks: 4
Thanked 0 Times in 0 Posts
Papajo is an unknown quantity at this point
Hyperlink Question

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>







PHP Code:
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>",""



Last edited by Papajo; 05-18-2009 at 08:29 PM..
Papajo is offline   Reply With Quote
Old 05-18-2009, 08:48 PM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,687
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
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.
__________________
Fumigator is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:59 AM.


Advertisement
Log in to turn off these ads.