Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

JAVA


  • Please log in to reply

#1
boob

boob

    Member

  • Member
  • PipPip
  • 74 posts
Here's the problem:
-I was asked to design a sample page of my work as a contruction business is looking for someone to make their web page. On the web page I was asked to put in 2 seperate banners of pictures of houses they have built all cycling through the different pics (banner one cycles through houses 1-7; banner two cycles through houses 8-14). The problem is, with my code I am only able to make one banner cycle. :tazz:

Here's my code:
<HTML>
<HEAD>
<TITLE> Cycling Banner Practice</TITLE>
<BODY>
<script>
imgArray = new Array(7);
imgArray[0] = new Image;
imgArray[0].src = "house1.jpg";
imgArray[1] = new Image;
imgArray[1].src = "house2.jpg";
imgArray[2] = new Image
imgArray[2].src = "house3.jpg";
imgArray[3] = new Image
imgArray[3].src = "house4.jpg";
imgArray[4] = new Image
imgArray[4].src = "house5.jpg";
imgArray[5] = new Image
imgArray[5].src = "house6.jpg";
imgArray[6] = new Image
imgArray[6].src = "house7.jpg";
index = 0;

function cycle ()
{
document.banner.src = imgArray[index].src;
index++;
if (index == 7)
{
index = 0;
}
setTimeout("cycle()",1000);
return;
}
</script>
<HEAD>
<BODY onLoad = "cycle();">
<CENTER>
<IMG SRC = "house1.jpg"
NAME = "banner"
WIDTH = 250

HEIGHT = 250>
</CENTER>
</BODY>
</HTML>

<HTML>
<HEAD>
<TITLE> Cycling Banner Practice</TITLE>
<BODY>
<script>
imgArray = new Array(7);
imgArray[0] = new Image;
imgArray[0].src = "house8.jpg";
imgArray[1] = new Image;
imgArray[1].src = "house9.jpg";
imgArray[2] = new Image
imgArray[2].src = "house10.jpg";
imgArray[3] = new Image
imgArray[3].src = "house11.jpg";
imgArray[4] = new Image
imgArray[4].src = "house12.jpg";
imgArray[5] = new Image
imgArray[5].src = "house13.jpg";
imgArray[6] = new Image
imgArray[6].src = "house14.jpg";
index = 0;

function cycle ()
{
document.banner.src = imgArray[index].src;
index++;
if (index == 7)
{
index = 0;
}
setTimeout("cycle()",1000);
return;
}
</script>
<HEAD>
<BODY onLoad = "cycle();">
<CENTER>
<IMG SRC = "house8.jpg"
NAME = "banner"
WIDTH = 250

HEIGHT = 250>
</CENTER>
</BODY>
</HTML>

Thanks alot for any help, I appreciate it.

Edited by boob, 01 June 2005 - 03:01 PM.

  • 0

Advertisements


#2
stu_design

stu_design

    Member

  • Member
  • PipPipPip
  • 217 posts
thers ur problem

u are ovewriting whatever that was in the variable b4

w8 let me explain

this is what u had in seperate scripts respectively

imgArray = new Array(7);
imgArray[0] = new Image;
imgArray[0].src = "house1.jpg";
imgArray[1] = new Image;
imgArray[1].src = "house2.jpg";
imgArray[2] = new Image
imgArray[2].src = "house3.jpg";
imgArray[3] = new Image
imgArray[3].src = "house4.jpg";
imgArray[4] = new Image
imgArray[4].src = "house5.jpg";
imgArray[5] = new Image
imgArray[5].src = "house6.jpg";
imgArray[6] = new Image
imgArray[6].src = "house7.jpg";

and

imgArray = new Array(7);
imgArray[0] = new Image;
imgArray[0].src = "house8.jpg";
imgArray[1] = new Image;
imgArray[1].src = "house9.jpg";
imgArray[2] = new Image
imgArray[2].src = "house10.jpg";
imgArray[3] = new Image
imgArray[3].src = "house11.jpg";
imgArray[4] = new Image
imgArray[4].src = "house12.jpg";
imgArray[5] = new Image
imgArray[5].src = "house13.jpg";
imgArray[6] = new Image
imgArray[6].src = "house14.jpg";

well see u are overwriting the array's value at say postion 3

imgArray[3] = new Image
imgArray[3].src = "house4.jpg";


imgArray[3] = new Image
imgArray[3].src = "house11.jpg";


*********************************
to make it work heres what i would do
delcare 2 arrays
one for the first banner
anotheer for the other

and have seperate functions

like cycle_one()
and cycle_2()

if u need more help
post back

STU DESIGN

Edited by stu_design, 02 June 2005 - 11:03 AM.

  • 0

#3
boob

boob

    Member

  • Topic Starter
  • Member
  • PipPip
  • 74 posts
Hey Stu, thanks alot for your reply. I remade the scripting with what I *thought* you said, but I believe that there must be something I am misunderstanding because it's not cycling them. What I changed was the array numbers in the second array and the addition to the cycles. Thanks alot for any help you have to offer.

Cody

Oh yeah, here's the new scripting:

<HTML>
<HEAD>
<TITLE> Cycling Banner Practice</TITLE>
<BODY>
<script>
imgArray = new Array(7);
imgArray[0] = new Image;
imgArray[0].src = "house1.jpg";
imgArray[1] = new Image;
imgArray[1].src = "house2.jpg";
imgArray[2] = new Image
imgArray[2].src = "house3.jpg";
imgArray[3] = new Image
imgArray[3].src = "house4.jpg";
imgArray[4] = new Image
imgArray[4].src = "house5.jpg";
imgArray[5] = new Image
imgArray[5].src = "house6.jpg";
imgArray[6] = new Image
imgArray[6].src = "house7.jpg";
index = 0;

function cycle1 ()
{
document.banner.src = imgArray[index].src;
index++;
if (index == 7)
{
index = 0;
}
setTimeout("cycle1()",1000);
return;
}
</script>
<HEAD>
<BODY onLoad = "cycle1();">
<CENTER>
<IMG SRC = "house1.jpg"
NAME = "banner"
WIDTH = 250

HEIGHT = 250>
</CENTER>
</BODY>
</HTML>

<HTML>
<HEAD>
<TITLE> Cycling Banner Practice</TITLE>
<BODY>
<script>
imgArray = new Array(7);
imgArray[7] = new Image;
imgArray[7].src = "house8.jpg";
imgArray[8] = new Image;
imgArray[8].src = "house9.jpg";
imgArray[9] = new Image
imgArray[9].src = "house10.jpg";
imgArray[10] = new Image
imgArray[10].src = "house11.jpg";
imgArray[11] = new Image
imgArray[11].src = "house12.jpg";
imgArray[12] = new Image
imgArray[12].src = "house13.jpg";
imgArray[13] = new Image
imgArray[13].src = "house14.jpg";
index = 1;

function cycle2 ()
{
document.banner2.src = imgArray[index].src;
index++;
if (index == 7)
{
index = 1;
}
setTimeout("cycle2()",1000);
return;
}
</script>
<HEAD>
<BODY onLoad = "cycle2();">
<CENTER>
<IMG SRC = "house8.jpg"
NAME = "banner2"
WIDTH = 250

HEIGHT = 250>
</CENTER>
</BODY>
</HTML>

Edited by boob, 02 June 2005 - 03:07 PM.

  • 0

#4
stu_design

stu_design

    Member

  • Member
  • PipPipPip
  • 217 posts
sorry 4 misunderstanding

here what do to

create 2 arrays

imgArray1 and imgArray2
fill the array with the data like

imgArray = new Array(7);
imgArray[7] = new Image;


now

create 2 functions
cycle1 and cycle2

now you just have to display the pictures

try what i said and if still niothin post back

ill actually try this out
i was just going by looking at ur code

Stu
  • 0

#5
stu_design

stu_design

    Member

  • Member
  • PipPipPip
  • 217 posts
alrite here goes

i know the problem on y u only getting i 2 work
but ur coding is to rough, not understandable

ok the problem is thtat u are placing the 2 arrays in the banner and only one can work at this

if you want to be able to run both at the same time then u have to figure out a way on displaying them,

if thats not what u doing tehn post back

but here is revised code

<HTML>
<HEAD>
<TITLE> Cycling Banner Practice</TITLE>
<BODY>

<script TYPE="text/javascript">
<!--

imgArray = new Array(7);
imgArray2 = new Array(7);
imgArray[0] = new Image;
imgArray[0].src = "house1.jpg";
imgArray[1] = new Image;
imgArray[1].src = "house2.jpg";
imgArray[2] = new Image
imgArray[2].src = "house3.jpg";
imgArray[3] = new Image
imgArray[3].src = "house4.jpg";
imgArray[4] = new Image
imgArray[4].src = "house5.jpg";
imgArray[5] = new Image
imgArray[5].src = "house6.jpg";
imgArray[6] = new Image
imgArray[6].src = "house7.jpg";

imgArray2 = new Array(7);
imgArray2[0] = new Image;
imgArray2[0].src = "house8.jpg";
imgArray2[1] = new Image;
imgArray2[1].src = "house9.jpg";
imgArray2[2] = new Image
imgArray2[2].src = "house10.jpg";
imgArray2[3] = new Image
imgArray2[3].src = "house11.jpg";
imgArray2[4] = new Image
imgArray2[4].src = "house12.jpg";
imgArray2[5] = new Image
imgArray2[5].src = "house13.jpg";
imgArray2[6] = new Image
imgArray2[6].src = "house14.jpg";


//to be used for imgArray in cycle1()
index = 0;
//to be used for imgArray2 in cycle2()
index2 = 0;


function cycle1() 
    {
       //put in code to display images with the loop
    }

function cycle2() 
    {
     //put in code to display images with the loop
    }



//-->
</SCRIPT>

//this is where the long happens: if u want both 2 run at same time
// then this is good if not then post back

// google "Body onLoad" for more info on it
<BODY onLoad = "cycle1();cycle2()">

</BODY>
</HTML>

Edited by stu_design, 03 June 2005 - 11:18 AM.

  • 0

#6
boob

boob

    Member

  • Topic Starter
  • Member
  • PipPip
  • 74 posts
Hey Stu,

I'm not exactly sure where to start inserting the code and where to stop in the parts where you typed to insert the scripting code. I'm not really very good in JAVA or any other programming language, I just started, so I'm getting a little lost. Thank you so much for all the help that you are giving me, I appologize if I'm troubling you at all.

Thanks again.
  • 0

#7
stu_design

stu_design

    Member

  • Member
  • PipPipPip
  • 217 posts
ok lets start with one banner
web pages, ithink, only have one banner

so if u want 2 at same time, i dont know but her's for just the one banner

<HTML>
<HEAD>
<TITLE> Cycling Banner Practice</TITLE>
<BODY>

<script TYPE="text/javascript">
<!--

imgArray = new Array(7);
imgArray2 = new Array(7);
imgArray[0] = new Image;
imgArray[0].src = "house1.jpg";
imgArray[1] = new Image;
imgArray[1].src = "house2.jpg";
imgArray[2] = new Image
imgArray[2].src = "house3.jpg";
imgArray[3] = new Image
imgArray[3].src = "house4.jpg";
imgArray[4] = new Image
imgArray[4].src = "house5.jpg";
imgArray[5] = new Image
imgArray[5].src = "house6.jpg";
imgArray[6] = new Image
imgArray[6].src = "house7.jpg";

//to be used for imgArray in cycle1()
index = 0;

function cycle1() 
   {
      document.banner.src = imgArray[index].src;
      index++;
      if (index == 7)
      {
      index = 0;
       }
   }

//-->
</SCRIPT>

//this is where the long happens: if u want both 2 run at same time
// then this is good if not then post back

// google "Body onLoad" for more info on it
<BODY onLoad = "cycle1()">

</BODY>
</HTML>

Ill look into doing it at 2 times at same time

Edited by stu_design, 06 June 2005 - 06:52 AM.

  • 0

#8
boob

boob

    Member

  • Topic Starter
  • Member
  • PipPip
  • 74 posts
Thanks alot for all your help Stu, contact me if you ever happen to come across the 2 cycling banners at the same time. Thank you.
  • 0

#9
bdlt

bdlt

    Member

  • Member
  • PipPipPip
  • 875 posts
here are a couple of alternate ideas

1. Front Page will generate multiple banners

2. use frames(one banner per frame). frames, however, are not supported by all browsers.
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP