#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    4
    Rep Power
    0
    Hi,

    I want to get the variabel name of multiple input type image with my php code. But I can get them with the same way to get varibel name of input type submit. Can anybody here fix it?

    Here is the example:

    <?
    if ($img_btn1) $value="image button 1";
    elseif ($img_btn2) $value="image button 2";
    elseif ($img_btn3) $value="image button 3";
    elseif ($btn) $value="submit button ";
    else $value="0";
    ?>

    <html>
    <body>
    <form>
    <input type=text name=txt value= <? echo $value; ?> >
    <input type=image name=img_btn1 src=img_btn1.png>
    <input type=image name=img_btn2 src=img_btn2.png>
    <input type=image name=img_btn3 src=img_btn3.png>
    <input type=submit name=btn value=submit>
    </form>
    </body>
    </html>

    When I press submit button, the text field show an approprite value.
    But it is not working with the image button.

    enka
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    Perth West Australia
    Posts
    757
    Rep Power
    15
    When you click an image button in a form the variables passed in the URL are buttonname.x and buttonname.y - x and y being the co-ordinates of the mouse click on the image (this bit I knew)

    What I did not realise was that 'cos PHP is v.clever it turns these variables into $buttonname_x and $buttonname_y !

    So Enka the code below works - give it a try

    <?php
    if ($btn1_x) $xvalue="image_button_1";
    elseif ($btn2_x) $xvalue="image_button_2";
    elseif ($btn3_x) $xvalue="image_button_3";
    elseif ($btn) $xvalue="submit_button";
    else $xvalue="0";
    ?>

    <html>
    <body>
    <?php ?>
    <form action="<?php echo $PHP_SELF;?>">
    <input type=text name=txt value= <? echo $xvalue; ?> >
    <input type=image name=btn1 src=img_btn1.png>
    <input type=image name=btn2 src=img_btn2.png>
    <input type=image name=btn3 src=img_btn3.png>
    <input type=submit name=btn value=submit>
    </form>
    </body>
    </html>

    Its all in the manual - you just have to really really look for it 'cos sometimes they hide it!

    Regards,
    Simon.

    ------------------
    Simon Wheeler
    FirePages -DHTML/PHP/MySQL
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    4
    Rep Power
    0
    Hi,

    Thanks, Simon. I've tried your codes. It works. And with this capability I think Php can do image map without html's tag for image map.

    regards,
    enka
  6. #4
  7. No Profile Picture
    Robert_J_Sherman
    Guest
    Devshed Newbie (0 - 499 posts)
    Okay, I've tried this, and it doesn't work for me.

    I can get the "x" value, that's no problem.

    I supposed that I could manage with just checking for that x value..

    if ($button_x) { ....

    but it doesn't seem totally a safe thing to do..

    Here's what I'm using:

    if ($send_x) $xvalue = "send_button";
    elseif ($save_x) $xvalue = "save_button";
    elseif ($review_x) $xvalue = "review_button";
    elseif ($delete_x) $xvalue = "delete_button";
    else $xvalue = "0";

    ------------------
    SnR Graphics,
    Low Cost Hosting and Web Development.
  8. #5
  9. No Profile Picture
    Robert_J_Sherman
    Guest
    Devshed Newbie (0 - 499 posts)
    Never mind, I got's it..

    DOH!

    ------------------
    SnR Graphics,
    Low Cost Hosting and Web Development.

Similar Threads

  1. how read input to pointer array, and catch them?
    By fs_allan in forum C Programming
    Replies: 2
    Last Post: February 7th, 2004, 03:45 PM
  2. Input Type=Image passing values in forms
    By mspokes in forum HTML Programming
    Replies: 0
    Last Post: January 6th, 2004, 09:28 AM
  3. IPtables help for rh8
    By climber in forum Linux Help
    Replies: 0
    Last Post: December 1st, 2003, 09:26 PM
  4. duplicate input in 2 form fields
    By hoagnes in forum PHP Development
    Replies: 3
    Last Post: September 8th, 2003, 08:56 PM
  5. grabbing a value from input type=image
    By mikeaflorida in forum HTML Programming
    Replies: 3
    Last Post: July 16th, 2003, 08:23 AM

IMN logo majestic logo threadwatch logo seochat tools logo