Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Oct 2008
    Posts
    28
    Thanks
    4
    Thanked 0 Times in 0 Posts

    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 09:29 PM.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •