Siczine.com
Posting Freak
   
Posts: 2351
Registered: 9-6-2005
Location: Philly
Member Is Offline
Mood: Cynical
|
|
Arrays?! WTF DOES IT MEAN?
Web Banner Code
I am trying to get more rotating banners and this code should do that, however, I am not quite sure what "//store the quotations in arrays" means.
Any help is greatly, greatly appreciated.
|
|
|
Siczine.com
Posting Freak
   
Posts: 2351
Registered: 9-6-2005
Location: Philly
Member Is Offline
Mood: Cynical
|
|
The above example is images of some of our different advertisers. If you refresh or reload the page in your browser, you should get a different image
(if you get the same, try again.) We wrote this basic script to allow viewers of your web page to get a new look each time they come to your web page.
Source code
|
|
|
BDx13
|
|
right now, you have four arrays, numbered 0, 1, 2, and 3.
if you want a wider variety of banners to display, you need to define the number you want, then define the details of each. so...
- change the number in "images = new Array(4);" to the number of banners you want to display. You want 12 different ads, make it "images = new
Array(12);" (without the quotation marks).
- then repeat "images[3] = " ";" (again, without the double quotes) a total of 12 times. be sure to change the number at the beginning, the URL
to which you want to direct your users when they click (that's the a href part) and the location of your banner ad (that's the img src part).
If I fail math, there goes my chance at a good job and a happy life full of hard work.
|
|
|
BDx13
|
|
lemme know if that's unclear, and i can try again.
If I fail math, there goes my chance at a good job and a happy life full of hard work.
|
|
|
Siczine.com
Posting Freak
   
Posts: 2351
Registered: 9-6-2005
Location: Philly
Member Is Offline
Mood: Cynical
|
|
Okay, so say I want four, is this what the part of code I would put in?
images = new Array(4)
images[0] = " ";
images[1] = " ";
images[2] = " ";
images[3] = " ";
index = Math.floor(Math.random() * images.length);
document.write(images[index]);
//done
// -->
|
|
|
Siczine.com
Posting Freak
   
Posts: 2351
Registered: 9-6-2005
Location: Philly
Member Is Offline
Mood: Cynical
|
|
Thanks for the help too by the way BD.
|
|
|
Siczine.com
Posting Freak
   
Posts: 2351
Registered: 9-6-2005
Location: Philly
Member Is Offline
Mood: Cynical
|
|
I'm a retard. But I finally got it. Thanks BD!
|
|
|
BDx13
|
|
yeah, you were just missing the top part that identifies the code a javascript.
so you got it working? if you need any other help, send me a u2u and i'll hook it up for ya.
If I fail math, there goes my chance at a good job and a happy life full of hard work.
|
|
|
Siczine.com
Posting Freak
   
Posts: 2351
Registered: 9-6-2005
Location: Philly
Member Is Offline
Mood: Cynical
|
|
Yo BD, one last question. Everything is fine but is there anyway I can get rid of the blue boarders?
|
|
|
BDx13
|
|
there is a border property for images that sets the size of the border around an image. by default, it's one pixel, but you can remove it by setting
it to zero:
img src='http://www.computerhope.com/banners/banner4.gif' alt='Computer Hope Newsletter' border='0'
just don't forget the beginning and end carrots (the < and > ) . If i include them in my post, it's not simply displaying the code, but actually
rendering it.
If I fail math, there goes my chance at a good job and a happy life full of hard work.
|
|
|
Siczine.com
Posting Freak
   
Posts: 2351
Registered: 9-6-2005
Location: Philly
Member Is Offline
Mood: Cynical
|
|
Yeah for some reason I figured because it had "//Javascript Created by Computerhope http://www.computerhope.com
//store the quotations in arrays" that all that should be excluded, completely forgetting most codes that end with a > need to begin with a <.
And thanks for the tip about the boarders, got that to work as well!
|
|
|
BDx13
|
|
great, glad to hear it.
If I fail math, there goes my chance at a good job and a happy life full of hard work.
|
|
|