Jump to content

Image change after x number of clicks???


dragonqueen

Recommended Posts

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!  ;D

 

 

Link to comment
https://forums.phpfreaks.com/topic/140139-image-change-after-x-number-of-clicks/
Share on other sites

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.