Click here to Skip to main content
14,639,719 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have a function showImg() which is suppose to display an image on the HTML page when displayed in the browser. ShowImg() function calls randonInteger(size) where size = 9. This function is stored in an external javascript file named "random.js".
I have to write an statement in showImg() function that will display image on the HTML page. I must use 'img' element

Note: My .html, .js, .jpg, .css files are all in the same folder.
Please help.
Jyoti
==========================================
function showImg()
    {  
        /*
            The showImg() function displays a random image from 0.jpg through 
        9.jpg   files.*/
        var imgNum = randomInteger(9); //Return a random # from 0 and 9
   /* 
   Here I have to write a statement that will display images on the document. I have to use :
      <img src = 'imgNum.jpg; alt ='' /> 
  */
        var imgSrc = imgNum + ".jpg";
    }
=============================================
Note: randomInteger(size) function is stored in an external javascript file named "random.js"


function randomInteger(size) {
    //alert("Inside randomInteger() function " + Math.floor((size+1)*Math.random()));

   return Math.floor((size+1)*Math.random());
}
Posted
Updated 3-Apr-12 7:31am
v2
Comments
ZurdoDev 3-Apr-12 13:31pm
   
Where is the question?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100