Results 1 to 2 of 2

Thread: how can i create a function?

  1. #1
    Join Date
    Jun 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how can i create a function?

    how can i add a hyperlink to each of images??that is what i meant...sorry
    for example:
    MMimages1[0] = "<a href='test/default.aspx'><img alt='test' src='test1/74650_01.jpg' border='0'></a>";
    ...any intructions?...thank a lot..

    my current code is below:
    Code:
    <script language="JavaScript" type="text/javascript"><!
    var MMimages1 = new Array();
    MMimages1[0] = "test1/74650_01.jpg";
    MMimages1[1] = "test1/74650_02.jpg";
    MMimages1[2] = "test1/74650_03.jpg";
    MM_preloadImages1(MMimages1);
    var timer1 = setTimeout("MM_swapImage1(MMimages1)", 5000);
    
    //></script>
    
    <div id="HeroPhoto"><img src="test1/74650_01.jpg" id="featuredArticle1" border="0"></div>
    <div id="FlipControls">
    <a onclick="MM_ClickSwap1(-);" href="javascript:void(0)">
    <img alt="previous" src="test1/prev.gif" border="0"></a><a onclick="MM_ClickSwap1(+);" href="javascript:void(0)">
    <img alt="next" src="test1/next.gif" border="0"></a>
    </div>
    
    
    =======
    [MM_ClickSwap1] source code
    =======
    var i=0;
    var a,b;
    
    	function MM_ClickSwap1(){
    
    	    var iClicker = MM_ClickSwap1.arguments[0];
    
    	    clearTimeout(timer1);
    	    
    	    if(iClicker == "-"){
    	        if(i <= 0)
    	            i=MMimages1.length-1;
    	        else
    	            i=i-1;
    	    }else if(iClicker == "+"){
    	        if(i >= MMimages1.length-1)
    	            i=0;
    	        else
    	            i=i+1;
    	    }else{
    	        i=iClicker;
    	    }
    	    
    	    MM_Swap1(MMimages1[i]);
    		timer1 = setTimeout("MM_swapImage1(MMimages1)", 5000);
    	}
    
    	
    
    	function MM_preloadImages1(){
    
    	var d=document;
    
    	    if(d.images){ 
    
    	        if(!d.MM_p) 
    	            d.MM_p=new Array();    
    
    	        var index,j=d.MM_p.length,a=MMimages1; 
    
    	        for(index=0; index<a.length; index++){ 
    	            d.MM_p[j] = new Image; 
    	            d.MM_p[j++].src = a[index];
    	        }
    
    	    }
    	}
    
    	
    
    	function MM_swapImage1(MMimages1){
    	   
    
    	        a = MMimages1;
    
    	   
    	    if(i<a.length){
    	    
    	        MM_Swap1(a[i]);
    	        i++;
    	        timer1 = setTimeout("MM_swapImage1(MMimages1)",5000);
    
    	    }else{
    	    
    	        MM_doSwap1(a[0]);
    	        i=0;
    	    
    	    }
    	}
    
    	
    
    	function MM_Swap1(srcImage){
    	    
    	    document.getElementById('featuredArticle1').src = srcImage;   
    	}
    Last edited by faceoff200337; 06-17-2008 at 01:34 PM. Reason: i got a warning message

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Syntax:
    ArrayName[arrayIndex] = "your_image_path/your_image_file_name.extension";
    Code:
    MMimages1[0] = "imgs/one.jpg";
    MMimages1[1] = "test/two.gif";
    MMimages1[2] = "test1/three.png";
    ----
    ----
    ----
    MMimages1[n] = "testn/n.gif";
    You can follow the above mentioned method I mean the using the index of the array you can specify new items but you need to increment it by one to access the next location.

Bookmarks

Posting Permissions

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