picture as a button

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jaymoore_299
Forum Contributor
Posts: 128
Joined: Wed May 11, 2005 6:40 pm
Contact:

picture as a button

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post 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".
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post 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.
dreamline
Forum Contributor
Posts: 158
Joined: Fri May 28, 2004 2:37 am

Post 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
Post Reply