View Full Version : Image to Checkbox

Jul 19th, 2009, 08:43 PM
It may sound simple, but so far it isn't. I'm helping out with a website with a page that is coded in php. In the file, there are tables set up. One has 6 checkboxes in a row.

The next are six pictures.

How do I make it so when you click on the pictures, the appropriate checkboxes will be checked?

Jul 19th, 2009, 11:55 PM
heres a quick example of how that works

its faster to learn this type of thing by example, the link contains a live test environment with my code in it for ya.

hope this was helpful!

Jul 19th, 2009, 11:56 PM
Use labels tags. You can do it in a couple of slightly different ways.

<label><img src="[path to image]"/>
<input type="checkbox" name="checkbox1" value="[value]"/>


<label for="checkbox1"><img src="[path to image]"/></label>
<input type="checkbox" id="checkbox1" name="checkbox1" value="[value]"/>

The second method is preferable, in my opinion. The 'for=' has to match the checkbox id to tie the label to the input.