Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.