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 5 of 5

Thread: whats wrong?

  1. #1
    Regular Coder
    Join Date
    Jul 2005
    Location
    LA, California
    Posts
    202
    Thanks
    0
    Thanked 0 Times in 0 Posts

    whats wrong?

    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd"
    >

    <
    html>

    <
    head>
      <
    title></title>
    <
    script language="JavaScript" type="text/javascript">
    <!--
    // Image Fade (23-07-2005)
    // by Vic Phillips [url]http://www.vicsjavascripts.org.uk[/url]

    var zxcSpeed=1;

    var 
    zxcIFU,zxcFD,zxcLok,zxcCnt,zxcTO,zxcOp;
    var 
    zxcFAry=new Array();

    function 
    zxcInitFadeDisplay(zxcm,zxct){
     
    zxcm=document.getElementById(zxcm);
     
    zxcimgs=document.getElementById(zxct).getElementsByTagName('IMG');
     for (
    zxc0=0;zxc0<zxcimgs.length;zxc0++){
      
    zxcimgs[zxc0].nu=zxc0;
      
    zxcimgs[zxc0].onclick=function(){ zxcFade(this.nu); }
      
    zxcFAry[zxc0]=document.createElement('IMG');
      
    zxcFAry[zxc0].style.position='absolute';
      
    zxcFAry[zxc0].style.width=zxcm.offsetWidth+'px';
      
    zxcFAry[zxc0].style.height=zxcm.offsetHeight+'px';
      
    zxcFAry[zxc0].style.zIndex=0;
      
    zxcFAry[zxc0].src=zxcimgs[zxc0].src;
      
    zxcOpacity(zxcFAry[zxc0],0);
      
    zxcm.appendChild(zxcFAry[zxc0]);
     }
     if (!
    zxcOp){ zxcFAry[0].style.zIndex=1; }

    }


    function 
    zxcFade(zxcnu){
     if (
    zxcLok&&zxcOp){ return; }
     
    zxcFU=zxcFAry[zxcnu];
     
    zxcFU.style.zIndex=1;
     if (
    zxcFD){ zxcFD.style.zIndex=0; }
     if (!
    zxcOp){ zxcFD=zxcFU; }
     
    zxcCnt=0;
     if (
    zxcFU!=zxcFD&&zxcOp){ zxcLok=truezxcFadeDo(); }
    }


    function 
    zxcFadeDo(){
     
    zxcCnt+=zxcSpeed;
     if (
    zxcFD){ zxcOpacity(zxcFD,100-zxcCnt); }
     
    zxcOpacity(zxcFU,zxcCnt);
     if (
    zxcCnt<100){ zxcTO=setTimeout("zxcFadeDo()",10); }
     else {
     
    zxcOpacity(zxcFU,100);
     if (
    zxcFD){ zxcOpacity(zxcFD,0); }
      
    zxcFD=zxcFU;
      
    zxcLok=false;
     }
    }


    function 
    zxcOpacity(obj,op){
     if (
    obj.style.MozOpacity!=null){ zxcOp=trueobj.style.MozOpacity=(op/100)-.001; }
     else if (
    obj.style.opacity!=null){ zxcOp=trueobj.style.opacity=(op/100)-.001; }
     else if (
    obj.style.filter!=null){ zxcOp=trueobj.style.filter 'alpha(opacity='+op+')';    }
    }

    function 
    onload() {
    var 
    num Math.round(Math.random());
    if (
    num == 0) { document.getElementById('Main').innerHTML "<img src=http://www.vicsjavascripts.org.uk/StdImages/zero.gif>"; }
    else if (
    num == 1) { document.getElementById('Main').innerHTML "<img src=http://www.vicsjavascripts.org.uk/StdImages/one.gif>"; }
    else if (
    num == 2) { document.getElementById('Main').innerHTML "<img src=http://www.vicsjavascripts.org.uk/StdImages/two.gif>"; }
    else if (
    num == 3) { document.getElementById('Main').innerHTML "<img src=http://www.vicsjavascripts.org.uk/StdImages/three.gif>"; }
    else if (
    num == 4) { document.getElementById('Main').innerHTML "<img src=http://www.vicsjavascripts.org.uk/StdImages/four.gif>"; }
    else { 
    document.getElementById('Main').innerHTML "<img src=http://www.vicsjavascripts.org.uk/StdImages/five.gif>"; }
    }

    //-->
    </script>

    </head>


    <body onload="zxcInitFadeDisplay('Main','Thumbs'); onload();" >
    <div  id="Main">
    </div>
    <br>
    <span id="Thumbs" >
    <img src="http://www.vicsjavascripts.org.uk/StdImages/Zero.gif" width=50 height=50 >
    <img src="http://www.vicsjavascripts.org.uk/StdImages/One.gif" width=50 height=50 >
    <img src="http://www.vicsjavascripts.org.uk/StdImages/Two.gif" width=50 height=50 >
    <br>
    <img src="http://www.vicsjavascripts.org.uk/StdImages/Three.gif" width=50 height=50 >
    <img src="http://www.vicsjavascripts.org.uk/StdImages/Four.gif" width=50 height=50 >
    <img src="http://www.vicsjavascripts.org.uk/StdImages/Five.gif" width=50 height=50 >
    </span>



    </body>

    </html> 
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    There are 3 kinds of ppl those who can count and those who cant
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    Script-Megafest.com Coming Oh so very soon

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    OK? You're making it impossible to help. Can you please let us know what you need help with?

  • #3
    Regular Coder
    Join Date
    Jul 2005
    Location
    LA, California
    Posts
    202
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yes, i got this code form vwphillips, and i want to make the the starting image random, i got it to be random but now the fade thing doesn't work
    this is the random function
    PHP Code:
    function onload() {
    var 
    num Math.round(Math.random());
    if (
    num == 0) { document.getElementById('Main').innerHTML "<img src=http://www.vicsjavascripts.org.uk/StdImages/zero.gif>"; }
    else if (
    num == 1) { document.getElementById('Main').innerHTML "<img src=http://www.vicsjavascripts.org.uk/StdImages/one.gif>"; }
    else if (
    num == 2) { document.getElementById('Main').innerHTML "<img src=http://www.vicsjavascripts.org.uk/StdImages/two.gif>"; }
    else if (
    num == 3) { document.getElementById('Main').innerHTML "<img src=http://www.vicsjavascripts.org.uk/StdImages/three.gif>"; }
    else if (
    num == 4) { document.getElementById('Main').innerHTML "<img src=http://www.vicsjavascripts.org.uk/StdImages/four.gif>"; }
    else { 
    document.getElementById('Main').innerHTML "<img src=http://www.vicsjavascripts.org.uk/StdImages/five.gif>"; }

    then i just added a onload(); to the body onload
    hope this is what you mean
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    There are 3 kinds of ppl those who can count and those who cant
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    Script-Megafest.com Coming Oh so very soon

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    if you want to get a random number between 0-5 (0 and 5 included), the best syntax is:

    var num = Math.floor(6 * Math.random());
    Last edited by Kor; 10-19-2005 at 08:30 AM.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,511
    Thanks
    3
    Thanked 504 Times in 491 Posts
    Code:
    <html>
    
    <head>
      <title></title>
    <script language="JavaScript" type="text/javascript">
    <!--
    // Image Fade (09-10-2005)
    // by Vic Phillips http://www.vicsjavascripts.org.uk
    
    var zxcSpeed=1;
    var zxcDelay=50;
    
    
    var zxcTO;
    var zxcFadeAry=new Array();
    var zxcCkOpacity=false;
    
    function zxcInitFadeDisplay(zxcm,zxct,zxci){
     zxcm=document.getElementById(zxcm);
     zxcimgs=document.getElementById(zxct).getElementsByTagName('IMG');
     zxcm.ary=new Array();
     for (zxc0=0;zxc0<zxcimgs.length;zxc0++){
      zxcm.ary[zxcm.ary.length]=zxcimgs[zxc0];
      zxcimgs[zxc0].nu=zxc0;
      zxcimgs[zxc0].ary=zxcm.ary;
      zxcimgs[zxc0].main=zxcm;
      zxcimgs[zxc0].onclick=function(){ zxcFade(this); }
      zxcm.ary[zxc0]=document.createElement('IMG');
      zxcm.ary[zxc0].style.position='absolute';
      zxcm.ary[zxc0].style.width=zxcm.offsetWidth+'px';
      zxcm.ary[zxc0].style.height=zxcm.offsetHeight+'px';
      zxcm.ary[zxc0].style.zIndex=0;
      zxcm.ary[zxc0].pl=new Image();
      zxcm.ary[zxc0].pl.src=zxcimgs[zxc0].title.split('^')[0];
      zxcm.ary[zxc0].src=zxcm.ary[zxc0].pl.src;
      zxcm.ary[zxc0].title=zxcimgs[zxc0].title.split('^')[1];
      zxcimgs[zxc0].title=zxcimgs[zxc0].title.split('^')[1];
      if (zxcimgs[2].style.MozOpacity!=null||zxcimgs[2].style.opacity!=null||zxcimgs[2].style.filter!=null){
       zxcCkOpacity=true;
       zxcOpacity(zxcm.ary[zxc0],0);
      }
      zxcm.appendChild(zxcm.ary[zxc0]);
      zxcm.ary[zxc0].cnt=0;
     }
     if (zxci){
      if (typeof(zxci)=='string'){
       zxci=Math.floor(zxcimgs.length * Math.random());
      }
      if (zxci<zxcimgs.length){
       zxcOpacity(zxcm.ary[zxci],100);
       zxcm.IT=zxcm.ary[zxci];
       zxcm.IT.cnt=100;
       if (zxcCkOpacity){ zxcOpacity(zxcm.ary[zxci],100); }
       else { zxcm.IT.style.zIndex=1; }
      }
     }
    }
    
    function zxcFade(zxcobj){
     if (zxcobj.main.IB){ zxcobj.main.IT=zxcobj.main.IB; }
     zxcobj.main.IB=zxcobj.ary[zxcobj.nu];
     if (!zxcCkOpacity){
      zxcobj.main.IB.style.zIndex=10;
      zxcobj.main.IT.style.zIndex=0;
      return;
     }
     if (!zxcobj.main.set){
      zxcobj.main.set=true;
      zxcFadeAry[zxcFadeAry.length]=zxcobj.main;
     }
     if (!zxcTO){ zxcFadeDo(); }
    }
    
    function zxcFadeDo(){
     zxcrund=false;
     for (zxc0=0;zxc0<zxcFadeAry.length;zxc0++){
      zxcOpacity(zxcFadeAry[zxc0].IT,zxcFadeAry[zxc0].IT.cnt);
      zxcOpacity(zxcFadeAry[zxc0].IB,zxcFadeAry[zxc0].IB.cnt);
      zxcFadeAry[zxc0].IT.cnt-=zxcSpeed;
      zxcFadeAry[zxc0].IB.cnt+=zxcSpeed;
      if (zxcFadeAry[zxc0].IT.cnt>0){ zxcrund=true; } else { zxcFadeAry[zxc0].IT.cnt=0; }
      if (zxcFadeAry[zxc0].IB.cnt<100){ zxcrund=true; }  else { zxcFadeAry[zxc0].IB.cnt=100; }
     }
     if (zxcrund){ zxcTO=setTimeout('zxcFadeDo()',zxcDelay); }
     else { zxcTO=null; }
    }
    
    
    function zxcOpacity(zxcobj,zxcop) {
     if (zxcop>100||zxcop<0){ return }
     if (zxcobj.style.MozOpacity!=null){ zxcobj.style.MozOpacity=(zxcop/100)-.001; }
     else if (zxcobj.style.opacity!=null){ zxcobj.style.opacity=(zxcop/100)-.001; }
     else if (zxcobj.style.filter!=null){ zxcobj.style.filter = 'alpha(opacity='+zxcop+')';	}
    }
    
    //-->
    </script>
    
    </head>
    
    
    <body onload="zxcInitFadeDisplay('Main','Thumbs','R');zxcInitFadeDisplay('Main2','Thumbs2',2);" >
    
    <div  id="Main" style="position:relative;width:200px;height:200px;" >
    </div>
    <br>
    <span id="Thumbs" >
    <img title="http://www.vicsjavascripts.org.uk/StdImages/Zero.gif^Zero" src="http://www.vicsjavascripts.org.uk/StdImages/Tick1.gif" width=50 height=50 >
    <img title="http://www.vicsjavascripts.org.uk/StdImages/One.gif^One" src="http://www.vicsjavascripts.org.uk/StdImages/Tick1.gif" width=50 height=50 >
    <img title="http://www.vicsjavascripts.org.uk/StdImages/Two.gif^Two" src="http://www.vicsjavascripts.org.uk/StdImages/Tick1.gif" width=50 height=50 >
    <br>
    <img title="http://www.vicsjavascripts.org.uk/StdImages/Three.gif^Three" src="http://www.vicsjavascripts.org.uk/StdImages/Tick1.gif" width=50 height=50 >
    <img title="http://www.vicsjavascripts.org.uk/StdImages/Four.gif^Four" src="http://www.vicsjavascripts.org.uk/StdImages/Tick1.gif" width=50 height=50 >
    <img title="http://www.vicsjavascripts.org.uk/StdImages/Five.gif^Five" src="http://www.vicsjavascripts.org.uk/StdImages/Tick1.gif" width=50 height=50 >
    </span>
    
    <br>
    <br>
    <span id="Thumbs2" >
    <img title="http://www.vicsjavascripts.org.uk/StdImages/Zero.gif^Zero" src="http://www.vicsjavascripts.org.uk/StdImages/Tick1.gif" width=50 height=50 >
    <img title="http://www.vicsjavascripts.org.uk/StdImages/One.gif^One" src="http://www.vicsjavascripts.org.uk/StdImages/Tick1.gif" width=50 height=50 >
    <img title="http://www.vicsjavascripts.org.uk/StdImages/Two.gif^Two" src="http://www.vicsjavascripts.org.uk/StdImages/Tick1.gif" width=50 height=50 >
    <br>
    <img title="http://www.vicsjavascripts.org.uk/StdImages/Three.gif^Three" src="http://www.vicsjavascripts.org.uk/StdImages/Tick1.gif" width=50 height=50 >
    <img title="http://www.vicsjavascripts.org.uk/StdImages/Four.gif^Four" src="http://www.vicsjavascripts.org.uk/StdImages/Tick1.gif" width=50 height=50 >
    <img title="http://www.vicsjavascripts.org.uk/StdImages/Five.gif^Five" src="http://www.vicsjavascripts.org.uk/StdImages/Tick1.gif" width=50 height=50 >
    </span>
    <div  id="Main2" style="position:relative;width:200px;height:200px;" >
    </div>
    <br>
    
    
    
    I'm trying to add two different galleries on one document.
    how would i implement that?
    
    
    how do i set the initial image when the the page is loaded? Icant seem to do it!<br>
    &lt;body onFilt="zxcInitFadeDisplay('*IDMain*','*IDThumbs*',*InitImg*);" ><br>
    where:
    *IDMain*   = the id name of the element to display the main image           (string)<br>
    *IDThumbs* = the id name of the element to containing the image information (string)<br>
    *InitImg*  = optional -the image number (in *IDThumbs*) to display on load  
                     String = Random
    (digit)<br>
    <br>
    I have also added image preload<br>
    
    
    </body>
    
    </html>


  •  

    Posting Permissions

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