adding JavaScript to header

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
btvngan
Forum Newbie
Posts: 3
Joined: Mon Dec 19, 2005 8:44 pm

adding JavaScript to header

Post by btvngan »

Hello,

I am new to php. I have been trying to add a banner rotator script to my header.php but not very sucessful. I need your help in adding the javascripts (banner rotator) to my existing header.

Here's what I got:

Code: Select all

<?php $thisfile = "header.php";if(SHOWFILENAMES == "on"){echo "<p class=\"filename\">This file is: " . $thisfile . "</p>";}?>
<!-- edit below this line -->
<!-- start of header.php -->
<table align="<?php echo PAGEALIGN;?>" width="<?php echo PAGEWIDTH;?>" class="favcolor">
	<tr>
		<td align="<?php echo PAGEALIGN;?>">
			<img src="<?php echo INSTALLPATH;?>images/header.jpg" width="<?php echo PAGEWIDTH;?>" height="115" border=0 alt="<?php echo IMPLEMENTATION_NAME;?>">
		</td>
	</tr>
	<tr>
		<td>
			<!-- table for icons - start -->
table is 800 x 115

I like to split the table into 2 columns: left side for the logo and right side (468 x 60) centered.

Here's the banner rotator scripts:

Code: Select all

<script language="JavaScript">
var imgs1 = new Array(
  "http://mitomortgage.com/images/ads/banner1.jpg",
  "http://mitomortgage.com/images/ads/banner2.jpg",
  "http://mitomortgage.com/images/ads/banner3.jpg",
  "http://mitomortgage.com/images/ads/banner4.jpg",
  "http://mitomortgage.com/images/ads/banner5.jpg",
  "http://mitomortgage.com/images/ads/banner6.jpg",
  "http://mitomortgage.com/images/ads/banner7.jpg",
  "http://mitomortgage.com/images/ads/banner8.jpg",
  "http://mitomortgage.com/images/ads/banner9.jpg",
  "http://mitomortgage.com/images/ads/banner10.jpg"
)
var lnks1 = new Array(
  "http://mitomortgage.com/index.php",
  "http://mitomortgage.com/index.php",
  "http://mitomortgage.com/index.php",
  "http://mitomortgage.com/index.php",
  "http://mitomortgage.com/index.php",
  "http://mitomortgage.com/index.php",
  "http://mitomortgage.com/index.php",
  "http://mitomortgage.com/index.php",
  "http://mitomortgage.com/index.php",
  "http://mitomortgage.com/index.php"
)
var alt1 = new Array(
  "Alt text for banner1",
  "Alt text for banner2",
  "Alt text for banner3",
  "Alt text for banner4",
  "Alt text for banner5",
  "Alt text for banner6",
  "Alt text for banner7",
  "Alt text for banner8",
  "Alt text for banner9",
  "Alt text for banner10"
)
var currentAd1 = 0
var imgCt1 = 10
function cycle1() {
  if (currentAd1 == imgCt1) {
    currentAd1 = 0
  }
var banner1 = document.getElementById('adBanner1');
var link1 = document.getElementById('adLink1');
  banner1.src=imgs1[currentAd1]
  banner1.alt=alt1[currentAd1]
  document.getElementById('adLink1').href=lnks1[currentAd1]
  currentAd1++
}
  window.setInterval("cycle1()",10000)
          </script>

Thank you!
Btvngan
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

Where do you need to put it?

well, put the JS in your page, put an image where you want to display banner and set its ID to adBanner1, surround it with an <A> tag ans set its ID to adLink1...
enjoy :wink:
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Moved to Client Side :D Code Snips is for posting code for others to use ;)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

btvngan, I just deleted your new thread with the title "?" and content "I have no idea what you're talking about"... Did you accidentally create a new thread rather than reply to this :?:
Post Reply