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 5 of 5
  1. #1
    New Coder
    Join Date
    Sep 2002
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problems with using an image for a submit button in a form

    I would like to use an image instead of an ugly submit button. Here is my code:

    <!--This doesn't work-->

    <form name='form$x' method='post' action='projLeads.php'> <input type='hidden' name='ID' value='$jobID'>
    <input type='image' src='images/remove.gif' alt='Delete' name='Delete' width='13' height='15'>
    </form>

    <!--This does-->

    <form name='form$x' method='post' action='projLeads.php'> <input type='hidden' name='ID' value='$jobID'>
    <input type='submit' name='Delete' value='Delete'>
    </form>

    This is the code that processes the form:

    <?PHP
    if($Delete) {
    $conn = db_connect();
    //declare query
    $query = 'DELETE FROM currProjects WHERE id="'.$ID.'"';
    //execute query
    $result = mysql_query($query);
    //declare query
    $query = 'DELETE FROM invoices WHERE id="'.$ID.'"';
    //execute query
    $result = mysql_query($query);
    //declare query
    $query = 'DELETE FROM contracts WHERE id="'.$ID.'"';
    //execute query
    $result = mysql_query($query);
    }
    ?>

    So the first bunch of coding is what I want to get to work. The second works. The third is just to give you a better idea as to what I'm trying to do, it works.

    How can I use the image submit button to work properly as a submit button?

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    -27 28' 22" , 153 1' 22"
    Posts
    135
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <!--This doesn't work-->

    <form name='form$x' method='post' action='projLeads.php'> <input type='hidden' name='ID' value='$jobID'>
    <input type='image' src='images/remove.gif' alt='Delete' name='Delete' width='13' height='15'>
    </form>
    THIS SHOULD WORK!!

    <form name="form$x" method="post" action="projLeads.php"> <input type='hidden' name='ID' value='$jobID'>
    <input type="image" action="submit" src="images/remove.gif" alt="Delete" name="Delete" width="13" height="15">
    </form>
    "Computers are considered female - As soon as you make a commitment to one, you find yourself spending half your paycheck on accessories for it."

  • #3
    New Coder
    Join Date
    Sep 2002
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Didn't work

    I did exactly as you indicated. I added the action="submit". The database row did not delete. When switching it with the ugly button it worked. I'm still lost as to what to do. You may be onto something though, keep thinking.

  • #4
    Regular Coder
    Join Date
    Sep 2002
    Location
    Burlington, VT
    Posts
    125
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question

    That is very wierd... I just did a lot of searching and this is the correct syntax for using an image as a submit button

    <input type="image" src="submit.gif" height="20" width="60" border="0" alt="Submit your info">

    whiiich is exactly what you have. hhmm..
    i wonder if your php script would take the "Delete" from another <input type="hidden" name="Delete" value="Delete"> like that? then just use the submit button...
    or maybe try adding the value in like it is in the ugly button form <input type="image" name="delete" value="delete">
    just throwing out ideas!
    Last edited by dauvm; 10-09-2002 at 05:57 AM.
    "The focused mind can pierce through stone."
    - Japanese Maxim

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Posts
    1,404
    Thanks
    2
    Thanked 32 Times in 32 Posts
    An <input type="image"> submit is a sort of $0.98 image map: it submits its own data to the server as:

    Delete.x=73&Delete.y=14

    ...where x & y are the left & top co-ordinates of the click point on the image. This is presumably to allow for a variety of submit possibilities, based on where the user clicked; in practice, it alters the format of the posted data. If you don't care to parse this out at the server, try:

    <form name="f1" onsubmit="return true;">
    <input type="hidden" name="Delete" value="Delete">
    <a href="javascript:if(document.f1.onsubmit())document.f1.submit()">
    <img border="0" src="images/remove.gif" alt="Delete" width="13" height="15"></a>
    </form>

    The Form.submit() method doesn't call the Form.onsubmit handler so the above does it explicitly; if you're not using an onsubmit validator, e.g., be sure and use the return true statement, or simply eliminate this completely:

    if(document.f1.onsubmit())

    cya, adios


  •  

    Posting Permissions

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