SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Addict
    Join Date
    Nov 2007
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry Undefined Error!!!!!!!!!!

    Am using this code to loop through banners in the database
    and it gave me UNDEFINED and when i view the source code of the page it displays them very well
    i checked the path and everything


    this is the code
    Code JavaScript:
    <script>
    	var t;
    	var ts;
    	{$jsTopBanners|strip}
    	{$jsSideBanners|strip}
     
     
    	var totalSlides=slides.length;
     
     
     
    	var totalSideSlides=Sideslides.length;
     
     
     
     
     
     
     
    	var currentSlide=-1;
     
     
     
    	var currentSideSlide=-1;
     
     
     
     
     
     
     
    	{literal}
     
     
     
    	function changeSlide()
     
     
     
    	{	
     
     
     
    		if(currentSlide==totalSlides-1)
     
     
     
    		{
     
     
     
    			currentSlide=-1;
     
     
     
    		}	
     
     
     
    		currentSlide++;
     
     
     
    		document.getElementById('topBanner').innerHTML=slides[currentSlide];		
     
     
     
    		t=setTimeout("changeSlide()",15000);
     
     
     
    	}
     
     
     
     
     
     
     
    	function changeSideSlide()
     
     
     
    	{	
     
     
     
    		//alert(currentSideSlide);
     
     
     
    		if(currentSideSlide==totalSideSlides-1)
     
     
     
    		{
     
     
     
    			currentSideSlide=-1;
     
     
     
    		}	
     
     
     
    		currentSideSlide++;
     
     
     
    		document.getElementById('sideBanner').innerHTML=Sideslides[currentSideSlide];
     
     
     
    		ts=setTimeout("changeSideSlide()",15000);
     
     
     
    	}
     
     
     
     
     
     
     
    	function callSlideFns()
     
     
     
    	{
     
     
     
    		if(totalSlides>0)
     
     
     
    		{
     
     
     
    			changeSlide();
     
     
     
    		}
     
     
     
    		if(totalSideSlides>0)
     
     
     
    		{
     
     
     
    			changeSideSlide();
     
     
     
    		}
     
     
     
    	}
     
     
     
    	{/literal}
     
     
     
    </script>
    <body bgcolor="#1E2225" onload="callSlideFns()">



    and the source code like that
    var Sideslides=new Array();Sideslides[10]='<a href=""><img src="admin/uploaded_files/video/1210684766_link_17.png" border="0" /></a>';

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It looks like that code is supposed to be run through some server-scripting language (like php, but not). It's not valid javascript the way it is.

  3. #3
    SitePoint Addict
    Join Date
    Nov 2007
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah the banners come from the database using php code
    but i dont know why its not working!!!

  4. #4
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Yeah, looks like smarty generated or something through PHP.

    What's the generated output?
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  5. #5
    SitePoint Evangelist
    Join Date
    Jul 2007
    Posts
    345
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The tags in curly braces are Smarty tags. Smarty is a PHP templating language.

    I think the problem with the code is that it loops through the slides from slide[0] to slide[10] but the source code only defines slide[10]. The other slides are undefined.

  6. #6
    SitePoint Addict
    Join Date
    Nov 2007
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the problem,that it never shows any banners and this is the source code
    var Sideslides=new Array();Sideslides[10]='<a href=""><img src="admin/uploaded_files/video/1210758993_link_17.png" border="0" /></a>';Sideslides[11]='<a href=""><img src="admin/uploaded_files/video/1210759210_link_17.png" border="0" /></a>';

  7. #7
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Right, it's looking for Sideslides[0] to start with, and doesn't look like you're defining it according to your latest post. You start with Sideslides[10] for some reason. Maybe you're using the same php count variable for Slides and Sideslides without resetting it?

    You could get away with not defining each SideSlides by index number but using:

    Code:
    var Sideslides=new Array();
    Sideslides.push('<a href=""><img src="admin/uploaded_files/video/1210758993_link_17.png" border="0" /></a>');
    Sideslides.push('<a href=""><img src="admin/uploaded_files/video/1210759210_link_17.png" border="0" /></a>');

  8. #8
    SitePoint Addict
    Join Date
    Nov 2007
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thnx for help,but i deleted all the images and put it from the start
    and nothing happens,although they appear if i put links instead of images
    this is my site
    http://vozenow.com/v1/browse.php?cty=1
    and i NOTICED that the image i upload ,appears sometimes
    i dont understand really whats going on!!!

  9. #9
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sideslides still starts at 10

    That is the problem

  10. #10
    SitePoint Addict
    Join Date
    Nov 2007
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeahh,i noticed that!!
    i removed all the banners from my localhost,and it starts at 0 and works fine
    i did so at the server,but it always begins with 10
    they r the same pages!!!!!
    what can i do now????

  11. #11
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ausge, you seem to be a big fan of typing many exclamation marks!!!



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
  •