Page 1 of 1
picture as a button
Posted: Thu Oct 20, 2005 10:25 pm
by jaymoore_299
If I have pictures named pic1 , pic2 , pic3
how would I make them into buttons so that clicking on them wouldn't send you anywhere, but they would be registered as being clicked, so that once you hit submit you'd go to the next page and know which ones were and were not clicked on? Right now I have radio buttons to the right of each picture but I'd rather make it easier and just have the ability to click on the picture itself.
Posted: Thu Oct 20, 2005 10:29 pm
by feyd
you can use image form controls, or simply add a link to the image that runs a bit of javascript that sets a hidden field to the image... there are a few more, but they are variants of the ones listed.
Posted: Fri Oct 21, 2005 12:54 am
by Burrito
I would create a js array and when the image is clicked, add the image id to the array, if it's unclicked strip it out of the array.
Then on your post, you can see which images were "selected" by looping through the array.
you could do something cool with the image too when it's clicked, like change the border, or make it step out a little bit to indicate that it was "selected".
Posted: Fri Oct 21, 2005 1:14 am
by Jenk
I'd probably make use of the onClick property, a quick JS function and possibly hidden values that wil then be checked after submitting.
Posted: Fri Oct 21, 2005 8:50 am
by dreamline
Yea i would do it like that too and it looks something like this from the top of my head:
Code: Select all
<a href="javascript: document.form1.submit();" onClick="document.form1.action='index.php?yourdesiredvariables'"><img src="image_name"></a>
If you want you can also add the javascript thingy so if someone hangs above your picture he sees the hand and knows it's clickable.
Hope this helps..

and hope i am right not to use PHP tags.. LOL