...

View Full Version : javaScript help!!



VietBoyVS
06-02-2004, 09:31 AM
Here is my code from scratch.

I want to prefetch all the images, then display a picture when a user press Next to show the next image in where the <img src=""> is, and below is showing the author in a text field. If they press Previous, will show the previous pix, and random show random.


ANy help plzzzzzzzzzzzzzzzzzzzzzz?????


<body>
<script language="javascript">

//var pixValues = new Array(totalPix);
var pixAuthor = new Array(totalPix);
var totalPix = 6;

for (i = 0; i < totalPix; i++) {
hangman[i]=new Image();
}

hangman[0].src="brownbox.gif";
pixAuthor [0] = "Name 1";
hangman[1].src="orangebox.gif";
pixAuthor[1] = "Name 2";
hangman[2].src="redbox.gif";
hangman[3].src="whitebox.gif";
hangman[4].src="bluebox.gif";
hangman[5].src="purplebox.gif";

function nextPix(){
//Show the next picture
document.images[ ].src=hangman[ ].src;
}

function previousPix(){
//Show previous picture
document.images[ ].src=hangman[ ].src;
}

function randPix(){
//Show random picture
hangman[ ]=randNum(totalPix);
}

function randNum(num) {
return Math.floor(Math.random()*num);
//Using Math.floor() to get a whole number, and Math.random()*num to get a random number and return the value
}

function showAuthor(){
//Show author

}
</script><center>
<form name="pixShow" method="post" >
<br><img src="brownbox.gif">
<br><br>
<input type="text" name="author" size="50" >
<br><br>
<input type="button" value=" BACK " onclick="nextPix()">
&nbsp; &nbsp; &nbsp;
<input type="button" value=" NEXT " onclick="previousPix()"> &nbsp; &nbsp; &nbsp;
<input type="button" value=" RANDOM " onclick="randPix()">

</form>
</center>
</body>

Willy Duitt
06-02-2004, 09:45 AM
What's the question?

VietBoyVS
06-02-2004, 05:07 PM
What's the question?


How do make the javascript recognizes to display a picture when a user press Next to show the next image in where the <img src=""> is, and below is showing the author in a text field. If they press Previous, will show the previous pix, and random show random.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum