SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2000
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello,

    I'm trying to find out which form button a user clicked.

    Because all of my from buttons are images I'm using:

    <form action ="?">
    <input type ="image" src="button1.gif" name = "Next" >
    <input type ="image" src="button2.gif" name = "Prev" >
    </form>

    Then when my php script receives this form, how do I test for which button was pressed please?

    I've tried:

    if ($Next):
    echo "next was pressed<br>";
    endif;

    if ($Prev):
    echo "Prev was pressed<br>";
    endif;

    and also.....


    if ($Next.x):
    echo "next was pressed<br>";
    endif;

    if ($Prev.x):
    echo "Prev was pressed<br>";
    endif;

    but none of these identify the button uniquely.

    Does anyone know if it's possible to determine which button was pressed using input type ="image" please?

    Thank you,

    Jason





  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Jason I do belive it is
    if ($Next_x > 0) {

    }
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, why is the variable's name weird, Freddy?
    I've never tried that before, but if s.o. does some tests, please let me know if it works
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just tested it and it works.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But why it has an _x after the name? Is that a rule? And how would you find such documentation? Thanks, Freddy
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  6. #6
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually I found out in another forum a while back, when I needed to do it, I couldn't find it in the docs, and yes I do belive its a rule, but I think its more of an html-server-side image map thing, basically your clicking on an image and the server knows how to get the coordiantes of where you clicked somehow.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  7. #7
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But what is weird is that if you use a get method in your form you will see imagename.x and imagename.y with the coordinates to where you clicked on the image, but you have to use imagename_x and imagename_y when you are checking to see whther the image was clicked, weird????
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  8. #8
    SitePoint Zealot
    Join Date
    Jun 2000
    Posts
    165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you Freddy!

    Regards,

    Jason


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
  •