|
Author |
Message |
feather
DaVinci Angel
Warnings:
Posts: 22
|
Little Javascript/HTML help |
Quote |
If you've been to Project "A", (hxxp://www.freewebs.com/feather-chan/Micros.html) (yeah, I know none of you have) you've seen I use javascript and some HTML buttons to turn the pages. This is essentially a system built by my comic program, though I adapted it.
Anyway, I'd like to add a drag-down menu, so you can jump right to a specific page. It seems to me like it should be simple, but without actually knowing Javascript I haven't been able to MacGuyver it into working. I'd like it not to have an ugly "Go" button.
Anyway, it would be appreciated if someone could code this for me. *bows*
Code follows (duh):
| | <script type="text/javascript" language="javascript">
var numPages = 3;
var curPage = 0; <!-- The Page currently being displayed-->
var pages = new Array(numPages);
pages[0] = "img/Micros/Page_1.jpg";
pages[1] = "img/Micros/Page_2.jpg";
pages[2] = "img/Micros/Page_3.jpg";
pages[3] = "img/Micros/Page_4.jpg";
pages[4] = "img/Micros/Page_5.jpg";
pages[5] = "img/Micros/Page_6.jpg";
pages[6] = "img/Micros/Page_7.jpg";
pages[7] = "img/Micros/Page_8.jpg";
pages[8] = "img/Micros/Page_9.jpg";
pages[9] = "img/Micros/Page_10.jpg";
pages[10] = "img/Micros/Page_11.jpg";
pages[11] = "img/Micros/Page_12.jpg";
pages[12] = "img/Micros/Page_13.jpg";
pages[13] = "img/Micros/Page_14.jpg";
pages[14] = "img/Micros/Page_15.jpg";
pages[15] = "img/Micros/Page_16.jpg";
function updateButtons() {
var nextButton = document.getElementById("nextButton");
var prevButton = document.getElementById("prevButton");
var firstButton = document.getElementById("firstButton");
var lastButton = document.getElementById("lastButton");
nextButton.disabled = curPage == numPages - 1;
prevButton.disabled = curPage == 0;
firstButton.disabled = curPage == 0;
lastButton.disabled = curPage == numPages - 1;
}
function nextPage() {
if (curPage < numPages - 1) {
curPage = curPage +1;
var image = document.getElementById("pageImage");
image.src = pages[curPage];
}
updateButtons();
}
function prevPage() {
if (curPage > 0) {
curPage = curPage - 1;
var image = document.getElementById("pageImage");
image.src = pages[curPage];
}
updateButtons();
}
function firstPage() {
if (curPage > 0) {
curPage = 0;
var image = document.getElementById("pageImage");
image.src = pages[curPage];
}
updateButtons();
}
function lastPage() {
if (curPage < numPages - 1) {
curPage = numPages - 1;
var image = document.getElementById("pageImage");
image.src = pages[curPage];
}
updateButtons();
}
</script> |
_________________ This space intentionally left blank. |
|
|
Sat Sep 22, 2007 3:27 am |
Profile PM
|
|
Azrael
Archangel of Death
Warnings:
Posts: 2
|
|
Quote |
hxxp://javascript.internet.com/generators/drop-down-menu.html
try this..
_________________
the secret method to get passwords to files, and access to the elite extra files board is revealed here |
|
|
Sat Sep 22, 2007 4:10 am |
Profile PM
|
|
feather
DaVinci Angel
Warnings:
Posts: 22
|
|
Quote |
It's not supposed to link to a new webpage, it runs a function that changes the image on the page. I think the function looks like this
| | function menu(Num) {
curPage = Num;
var image = document.getElementById("pageImage");
image.src = pages[curPage];
updateButtons();
} |
EDIT: I've just tested it, and it does work perfectly.
_________________ This space intentionally left blank. |
Last edited by feather on Sat Sep 22, 2007 4:58 am; edited 2 times in total |
|
Sat Sep 22, 2007 4:34 am |
Profile PM
|
|
Azrael
Archangel of Death
Warnings:
Posts: 2
|
|
Quote |
hmm..
so rather then move to a new page, it moves to a new picture on the same page? possibly i might have a friend that could make it work with the code i mentioned, because i'm not quite that great at javascript, i'm pretty good with html.. but my JS is lacking lol
_________________
the secret method to get passwords to files, and access to the elite extra files board is revealed here |
|
|
Sat Sep 22, 2007 4:42 am |
Profile PM
|
|
feather
DaVinci Angel
Warnings:
Posts: 22
|
|
Quote |
Well, I think all I need is a menu that calls a function, sending it a variable. The variable should be the value of the option. >.> that's in the HTML, isn't it?
_________________ This space intentionally left blank. |
|
|
Sat Sep 22, 2007 4:46 am |
Profile PM
|
|
feather
DaVinci Angel
Warnings:
Posts: 22
|
|
Quote |
Totally bumped. In my mind, this should work, but it doesn't.
| | <form>
<select name="menu" onChange="menu(value)">
<option value="0">1</option>
<option value="1">2</option>
<option value="2">3</option>
<option value="3">4</option>
</select>
</form> |
Wait, should I be using parentheses there or one of the other bracket sets?
_________________ This space intentionally left blank. |
|
|
Mon Sep 24, 2007 3:48 am |
Profile PM
|
|
|
|
|
You can post new threads in this forum You can reply to threads in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
Do not upload or mention any illegal content. Violators will be reported to the authorities. You are responsible for your uploads and actions.
If it is illegal for you to view adult lolikon material in your current location, leave this site immediately.
LAH is in compliance with DMCA.
|