SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: image in form

  1. #1
    SitePoint Addict nimasdj's Avatar
    Join Date
    Dec 2007
    Posts
    314
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    image in form

    I need an form like this, each lock.gif send an id value alongwith hidden field "do":

    <form method="get" action="download.php">
    <input type="hidden" name="do" value="something" />
    <input type="image" name="id" value="6" src="lock.gif" alt="" />
    <input type="image" name="id" value="7" src="lock.gif" alt="" />
    </form>

    By clicking the first image I expect to have this:
    /download.php?do=something&id.x=10&id.y=11&id=6
    but I just get this:
    /download.php?do=something&id.x=10&id.y=11

    If instead, I use:
    <form method="post" action="download.php">
    <input type="hidden" name="do" value="something" />
    <input type="hidden" name="id" value="6" />
    <input type="image" src="lock.gif" />
    </form>

    Of course it works, but problem is that the value of "id" is fetched from db, and this form will be created in foreach the db query array, and each row has its own "id", so if I use the form above in <tr> field, however it works but cannot be W3 validated as <form> should be outside <table> this is why I need something like the first one that I can put the form tag outside table tag and in each row just have the image to submit them W3 validated. Please help for this.

  2. #2
    SitePoint Addict nimasdj's Avatar
    Join Date
    Dec 2007
    Posts
    314
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any advice yet?

  3. #3
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,331
    Mentioned
    463 Post(s)
    Tagged
    8 Thread(s)
    It's not really clear what you are asking or what the issue is. You obviously can't have the same name value on multiple elements. You can wrap input in divs etc. if needed.

  4. #4
    SitePoint Addict nimasdj's Avatar
    Join Date
    Dec 2007
    Posts
    314
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I ask how is possible to use an image/icon to submit a value in form? I am not talking abput submit button but using type=image, in a form to pass a value?

  5. #5
    SitePoint Addict nimasdj's Avatar
    Join Date
    Dec 2007
    Posts
    314
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No idea yet?

  6. #6
    Community Advisor silver trophybronze trophy
    dresden_phoenix's Avatar
    Join Date
    Jun 2008
    Location
    Madison, WI
    Posts
    2,821
    Mentioned
    34 Post(s)
    Tagged
    2 Thread(s)
    just so you know: testing ( safari/FF on mac) your code I do get:

    download.php?do=something&id.x=349&id.y=34&id=6


    what browser are you using?

  7. #7
    SitePoint Addict nimasdj's Avatar
    Join Date
    Dec 2007
    Posts
    314
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    Did you test it with more than one image in the same form and by clicking each of them you got appropriate id in url? Please let me know this.
    I tested it with IE, what did you test it with?


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
  •