1 reply [Last post]
ProPokerUK
ProPokerUK's picture
Offline
Regular
Reading, UK
Last seen: 1 year 24 weeks ago
Reading, UK
Timezone: GMT+1
Joined: 2017-11-05
Posts: 11
Points: 18

Hi, Complete newbie with JS.

Looking for ideas on JavaScript code to change an image on button-click.

My website is "under construction", the image changes are to show it is a "working" holding page.
Hopefully to keep visitors' interest.
(The library of images will be changed fairly often while the site is built).

Several images available, all with same name plus a number ...
eg: ppImg1, ppImg2, ... ppImg9, ppImg10, etc.

Basic idea is to have a counter set to zero the first time the page is brought up.
Then incremented whenever the "Change Picture" button is clicked.

Any advice / comments / links are welcome.

:smiley: cheers

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 20 hours 43 min ago
Dallas
Timezone: GMT-5
Joined: 2004-06-25
Posts: 9743
Points: 3822

Not quite what you're asking for

See my Swapping Images demo. It should give you a start. Where I used a separate, explicit link for each image, have your js loop through the list of image links.

Your goal of switching on click is good from the user's viewpoint. Auto-changing 'slide shows' are annoying. As a user, I prefer the use of thumbnails over a blind change. It means I can go/return to the image/s that interest me instead of having to cycle through or wait for the slide to come up.

Please pardon the condition of my site. I've been retired for quite a while and have let maintenance slip badly.

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.