SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2004
    Location
    Body
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    IE and type="image" submit buttons...

    So apparently there are some shenanigans going on with IE and using type="image" to create your own submit button.

    Here's my submit button:
    Code:
    <input type="image" src="Graphics/pageelements/button.gif" name="dp" value="<? echo $did; ?>" />

    My first attempt was just to check and do something based on whether or not 'dp' contains a value:
    Code:
    if (isset($_POST['dp'])){
    //do something
    }
    Great.. this works in FF, but try it in IE, and the post variable for 'dp' doesn't pass. 'dp' isn't equal to anything in IE, so no code executes. So I do a little Googling, and find out IE is a P.O.S. for yet one more reason, and I find I need to use this solution:

    Code:
    if (isset($_POST['dp']) || isset($_POST['dp_x'])) {
    $dp=$_POST['dp'];
    This solution executes the code, but doesn't actually give me the value of 'dp'. So if I just want to do something like display text, isset($_POST['dp_x
    ]) is set and contains a value, so it will do it. But if I want to run a query based on what the value of 'dp' is, I can't, because I can't figure out how to access that post value of 'dp'. $dp=$_POST['dp'] doesn't work.


    Thaks for your time, any help would be appreciated.

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Do not use submit buttons to transfer data, use a hidden field for that.
    Cannot guarantee that a submit button will actually be returned.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want to use different submit buttons as a way to choose a value between a set(instead of using a radio or select menu), just give the buttons different names. If the form is submitted, yet none of buttons can be detected, you should assume the button which appears textually first in the html source.

    Check for foo_x, bar_x etc...

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,824
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    That button is supposed to pass two values x and y which give the position within the image where the mouse cursor was when the button was processed. Those are the only values that are supposed to be there for that field however Firefox gets it wrong and passes an additional value.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Bookmarks

Posting Permissions

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