/    Sign up×
Community /Pin to ProfileBookmark

Script for dynamic buttons? Help, please!

Recently, I’ve been working on programming a site for my friend’s webcomic, and it has been going well. I don’t really know JavaScript, so I am using a few different sites to try to find pre-made scripts that will function. So far, I have found all that I have needed, until I come to the buttons. The buttons are:

Next
Previous
Home
Start

For home and start, I shouldn’t need script. I can just hardwrite them when the site changes. The Next and Previous buttons, on the other hand, are much more difficult. I am using inline frames for the comic panel and the news panel, so I am looking for ways for the buttons to be static. That means, I need it to look at which comic/news it is showing and then go to the next or previous one. Is there any way to do this with JS or will I have to go to PHP for the answer?

Thanks for the help.

P.S. If PHP is the only answer, could someone direct me in the right direction on how to do this in PHP or a good place to learn PHP? Thanks for all the help.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@TheBearMayJan 23.2004 — Assuming you are loading new pages into the frames you could do something like:

[code=php]

var comicArray=["urlComic1", "urlComic2"....]
var comicInx = 0;

function nextComic(){
comicInx++;
if (comicInx>comicArray.length-1) comicInx=0;
comicFrame.src=comicArray[comicInx];
}

function prevcomic(){
comicInx--;
if (comicInx<0} comicInx=comicArray.length-1;
comicFrame.src=comicArray[comicInx];
}

....
<iframe id="comicArray"...
<button onclick="nextComic();">Next</button>
<button onclick="prevComic();">Prev</button>
[/code]
×

Success!

Help @MindFlayerMagi spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...