...

View Full Version : whats wrong?



Al_90
10-18-2005, 10:13 PM
<!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 http://www.vicsjavascripts.org.uk

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=true; zxcFadeDo(); }
}


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=true; obj.style.MozOpacity=(op/100)-.001; }
else if (obj.style.opacity!=null){ zxcOp=true; obj.style.opacity=(op/100)-.001; }
else if (obj.style.filter!=null){ zxcOp=true; obj.style.filter = 'alpha(opacity='+op+')'; }
}

function onload() {
var num = Math.round(5 * 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>

Brandoe85
10-18-2005, 10:50 PM
OK? You're making it impossible to help. Can you please let us know what you need help with? :confused:

Al_90
10-18-2005, 10:59 PM
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


function onload() {
var num = Math.round(5 * 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

Kor
10-19-2005, 08:22 AM
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());

vwphillips
10-19-2005, 05:44 PM
<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>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum