dragonqueen Posted January 9, 2009 Share Posted January 9, 2009 I'd like to offer graphics that 'grow' on my site. If you've been to Valenth.com, it's sort of like that. An image will change after a certain # of clicks. I'm fairly certain it can be done with JavaScript but I haven't coded in so long, I don't know where to begin. If someone could help me write the script I'd be forever grateful! Quote Link to comment https://forums.phpfreaks.com/topic/140139-image-change-after-x-number-of-clicks/ Share on other sites More sharing options...
Adam Posted January 9, 2009 Share Posted January 9, 2009 JavaScript wouldn't be the best solution - if a solution at all. You'd need to use PHP.. Have each link on the image point to a page like: click.php?img=12345 .. With 12345 being the image id. Setup a database to hold the data for each image, including image id, url, clicks, etc. When they go to click.php you take the input ID, update the database table for that image, increasing the "click" value by 1. Then redirect to the image URL.. If you want somebody to do all this for you, you may be better posting in the freelance forum.. A Quote Link to comment https://forums.phpfreaks.com/topic/140139-image-change-after-x-number-of-clicks/#findComment-733251 Share on other sites More sharing options...
Lautarox Posted January 9, 2009 Share Posted January 9, 2009 Mmm.. you could make a image bigger with a simple javascript function.. var click = 0; function makeBigger(imgid) { var value=10; document.getElementById(imgid).width = document.getElementById(imgid).width +click*value; document.getElementById(imgid).width = document.getElementById(imgid).width + click*value; click++; } I think this will work, take a look here http://www.w3schools.com/htmldom/prop_img_height.asp http://www.w3schools.com/htmldom/prop_img_width.asp Quote Link to comment https://forums.phpfreaks.com/topic/140139-image-change-after-x-number-of-clicks/#findComment-733399 Share on other sites More sharing options...
Psycho Posted January 9, 2009 Share Posted January 9, 2009 It can only be done with JavaScript if you want the image to reset for each page load. If you want the image to grow based upon ALL user clicks, then JavaScript will not work. Quote Link to comment https://forums.phpfreaks.com/topic/140139-image-change-after-x-number-of-clicks/#findComment-733412 Share on other sites More sharing options...
Lautarox Posted January 9, 2009 Share Posted January 9, 2009 mjdamato is right, that function will only grow the image in a client side way, you may have to use ajax to save the clicks and sure you'll need another language to show for the first time the growth image, it's not difficult.. Quote Link to comment https://forums.phpfreaks.com/topic/140139-image-change-after-x-number-of-clicks/#findComment-733413 Share on other sites More sharing options...
dragonqueen Posted January 11, 2009 Author Share Posted January 11, 2009 Thanks so much for the help and advice! I will check out the links provided and php solutions. Quote Link to comment https://forums.phpfreaks.com/topic/140139-image-change-after-x-number-of-clicks/#findComment-734782 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.