Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2004
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question javaScript help!!

    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?????
    Code:
    <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>

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What's the question?

  • #3
    New Coder
    Join Date
    Jan 2004
    Posts
    61
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question

    Quote Originally Posted by Willy Duitt
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •