SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2003
    Location
    boston
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Selecting Multiple Pictures Using Javascript

    I'm trying to build/use an application where people could be presented 10 thumbnails of pictures, and then click on a few of them using javascript, and then hit the submit button to save and submit that they choose say 3 pictures. I guess the fact that they're pictures isn't important, since maybe it could be anything in a div tag. But I was wondering if anybody knew of some existing code that could be used to do something like this?

  2. #2
    SitePoint Enthusiast Tygatur's Avatar
    Join Date
    Apr 2006
    Location
    Germany
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <input type="checkbox" name="imageName" /><img src="mypicture.png" onclick="this.previousSibling.checked=(!this.previousSibling.checked)" />

    In this case the checkbox needs to be directly before the picture itself, because this code uses the DOM-reference previousChild(=pointing to the Element just before itself).

    edit: I've got a better idea (pure HTML) :
    <input type="checkbox" id="picture42" />
    <label for="picture42"><img src="blabla.png" /></label>
    Last edited by Tygatur; May 6, 2007 at 08:34. Reason: better idea
    to code or not to code ?
    that's too much of a question for a signature.

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2003
    Location
    boston
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the quick reply. I tried using the second idea, do I need a name for the checkboxes? I gave it a name and tried to read that in PHP but it didn't work...sorry I'm not great at javascript, thanks for the help.


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
  •