Link to home
Start Free TrialLog in
Avatar of armasmike
armasmike

asked on

javascript code need help again.

well i am back but i think this is a lot easier then the last one.

i want to change the TD background image this is what i got

the index.html

<HTML>
<HEAD>
<script language="JavaScript" type="text/javascript" src="image.js.php"></script>
</HEAD>
<BODY onLoad="runSlideShow()">

<table>

<TD  WIDTH=836 HEIGHT=120 id="cell1"  background="_userimg-top.jpg">
</td>
 
</table>
</body>
</HTML>

Open in new window



this is my JavaScript file


<?php 



# You can mix php and javascript in this file as long as you give it a .php extension


$mikestuff = new userdata("Mike-cellutronics-co-nz");

if ( $mikestuff->get("header1") == "" )

{ $mikestuff->set("header1", "NONE"); }

if ( $mikestuff->get("header2") == "" )

{ $mikestuff->set("header2", "NONE"); }

if ( $mikestuff->get("header3") == "" )

{ $mikestuff->set("header3", "NONE"); }

if ( $mikestuff->get("header4") == "" )

{ $mikestuff->set("header4", "NONE"); }

if ( $mikestuff->get("header5") == "" )

{ $mikestuff->set("header5", "NONE"); }

if ( $mikestuff->get("header6") == "" )

{ $mikestuff->set("header6", "NONE"); }

if ( $mikestuff->get("header7") == "" )

{ $mikestuff->set("header7", "NONE"); }

if ( $mikestuff->get("header8") == "" )

{ $mikestuff->set("header8", "NONE"); }

if ( $mikestuff->get("header9") == "" )

{ $mikestuff->set("header9", "NONE"); }

if ( $mikestuff->get("header10") == "" )

{ $mikestuff->set("header10", "NONE"); }

?>



// =======================================

// set the following variables

// =======================================



// Set slideShowSpeed (milliseconds)
var slideShowSpeed		= "5000"		// SHOW THE DATE ON THE PAGE



// Duration of crossfade (seconds)
var crossFadeDuration		= "3"		// SHOW THE DATE ON THE PAGE




// Specify the image files

var Pic = new Array() // don't touch this
var Link = new Array()

// to add more images, just continue you might have to add the url like www.name.com/images

// the pattern, adding to the array below



var header1 ="<? echo $mikestuff->get("header1"); ?>"	

if ( header1 == "NONE" ) {
   header1path = "/sohoadmin/program/modules/site_templates/pages/Mike-cellutronics-co-nz/_userimg-top.jpg";
} else {
   header1path = "/images/"+header1;
}

var header2 ="<? echo $mikestuff->get("header2"); ?>"	

if ( header2 == "NONE" ) {
   header2path = "/sohoadmin/program/modules/site_templates/pages/Mike-cellutronics-co-nz/_userimg-header2 - Copy.jpg";
} else {
   header2path = "/images/"+header2;
}


var header3 ="<? echo $mikestuff->get("header3"); ?>"	

if ( header3 == "NONE" ) {
   header3path = "/sohoadmin/program/modules/site_templates/pages/Mike-cellutronics-co-nz/_userimg-top.jpg";
} else {
   header3path = "/images/"+header3;
}

var header4 ="<? echo $mikestuff->get("header4"); ?>"	

if ( header4 == "NONE" ) {
   header4path = "/sohoadmin/program/modules/site_templates/pages/Mike-cellutronics-co-nz/_userimg-top.jpg";
} else {
   header4path = "/images/"+header4;
}

var header6 ="<? echo $mikestuff->get("header6"); ?>"	

if ( header6 == "NONE" ) {
   header6path = "/sohoadmin/program/modules/site_templates/pages/Mike-cellutronics-co-nz/_userimg-top.jpg";
} else {
   header6path = "/images/"+header6;
}

var header5 ="<? echo $mikestuff->get("header5"); ?>"	

if ( header5 == "NONE" ) {
   header5path = "/sohoadmin/program/modules/site_templates/pages/Mike-cellutronics-co-nz/_userimg-top.jpg";
} else {
   header5path = "/images/"+header5;
}

var header7 ="<? echo $mikestuff->get("header7"); ?>"	

if ( header7 == "NONE" ) {
   header7path = "/sohoadmin/program/modules/site_templates/pages/Mike-cellutronics-co-nz/_userimg-top.jpg";
} else {
   header7path = "/images/"+header7;
}

var header8 ="<? echo $mikestuff->get("header8"); ?>"	

if ( header8 == "NONE" ) {
   header8path = "/sohoadmin/program/modules/site_templates/pages/Mike-cellutronics-co-nz/_userimg-top.jpg";
} else {
   header8path = "/images/"+header8;
}

var header9 ="<? echo $mikestuff->get("header9"); ?>"	

if ( header9 == "NONE" ) {
   header9path = "/sohoadmin/program/modules/site_templates/pages/Mike-cellutronics-co-nz/_userimg-top.jpg";
} else {
   header9path = "/images/"+header9;
}

var header10 ="<? echo $mikestuff->get("header10"); ?>"	

if ( header10 == "NONE" ) {
   header10path = "/sohoadmin/program/modules/site_templates/pages/Mike-cellutronics-co-nz/_userimg-top.jpg";
} else {
   header10path = "/images/"+header10;
}

Pic[0] = 'http://<? echo $_SESSION['docroot_url']; ?>'+header1path+''
Link[0] = 'http://<? echo $_SESSION['docroot_url']; ?>'+header1path+''

Pic[1] = 'http://<? echo $_SESSION['docroot_url']; ?>'+header2path+''
Link[1] = 'http://<? echo $_SESSION['docroot_url']; ?>'+header2path+''

Pic[2] = 'http://<? echo $_SESSION['docroot_url']; ?>'+header3path+''
Link[2] = 'http://<? echo $_SESSION['docroot_url']; ?>'+header3path+''

Pic[3] = 'http://<? echo $_SESSION['docroot_url']; ?>'+header4path+''
Link[3] = 'http://<? echo $_SESSION['docroot_url']; ?>'+header4path+''

Pic[4] = 'http://<? echo $_SESSION['docroot_url']; ?>'+header5path+''
Link[4] = 'http://<? echo $_SESSION['docroot_url']; ?>'+header5path+''

Pic[5] = 'http://<? echo $_SESSION['docroot_url']; ?>'+header6path+''
Link[5] = 'http://<? echo $_SESSION['docroot_url']; ?>'+header6path+''

Pic[6] = 'http://<? echo $_SESSION['docroot_url']; ?>'+header7path+''
Link[6] = 'http://<? echo $_SESSION['docroot_url']; ?>'+header7path+''

Pic[7] = 'http://<? echo $_SESSION['docroot_url']; ?>'+header8path+''
Link[7] = 'http://<? echo $_SESSION['docroot_url']; ?>'+header8path+''

Pic[8] = 'http://<? echo $_SESSION['docroot_url']; ?>'+header9path+''
Link[8] = 'http://<? echo $_SESSION['docroot_url']; ?>'+header9path+''

Pic[9] = 'http://<? echo $_SESSION['docroot_url']; ?>'+header10path+''
Link[9] = 'http://<? echo $_SESSION['docroot_url']; ?>'+header10path+''






// =======================================

// do not edit anything below this line

// =======================================



var t

var j = 0

var p = Pic.length



var preLoad = new Array()

for (i = 0; i < p; i++){

   preLoad[i] = new Image()

   preLoad[i].src = Pic[i]

}



function runSlideShow(){


   if (document.all){

      document.getElementById('cell1').style.filter="blendTrans(duration=2)"

      document.getElementById('cell1').style.filter="blendTrans(duration=crossFadeDuration)"

      document.getElementById('cell1').filters.blendTrans.Apply()      

   }

   document.getElementById('cell1').background = preLoad[j]

   

   if (document.all){

      document.getElementById('cell1').filters.blendTrans.Play()

   }

   j = j + 1

   if (j > (p-1)) j=0

   t = setTimeout('runSlideShow()', slideShowSpeed)

}

Open in new window



it kind of works the _userimg-top.jpg shows then fades away but the other image nevers shows. And this doesn't work in firefox only IE.
Avatar of armasmike
armasmike

ASKER

well never mind i out it working

i changed  

preLoad[i].src = Pic[i]

Open in new window


 to

 preLoad[i].url = Pic[i]

Open in new window


and

document.getElementById('cell1').background = preLoad[j]

Open in new window


to

document.getElementById('cell1').background = preLoad[j].url

Open in new window

it still only works in IE how can i get it to work in Firefox and chrome?
have you ever considered using jquery, it is cross browser capable.
Yes i would love to but i don't know how to write it
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I do need to get with the time and update my old code. Thank you