Meaningless Drivel is fun!*
The moose likes HTML, CSS and JavaScript and the fly likes A simple javascript and html quest Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "A simple javascript and html quest" Watch "A simple javascript and html quest" New topic
Author

A simple javascript and html quest

Tony Lavalle
Ranch Hand

Joined: Jan 18, 2005
Posts: 36
I have a small conundrum.

here is my script:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>St Cloud Orthopedics Associates, LTD.</title>
<link href="ortho.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
var pic_width=100;
var pic_height=100;

/* define image urls */

if (document.images)
{
pic1= new Image(pic_width,pic_height);
pic1.src="/images/O2C.gif";
pic2= new Image(pic_width,pic_height);
pic2.src="/images/S2C.gif";

}

/* define text for image captions */


var pics= new Array(2)
pics[0]=pic1.src;
pics[1]=pic2.src;



var numpics=2;
var thenum=0;
imgName="logo";

function change_it()
{
if (document.images)
{
document.write("<img src='"+pics[thenum]+"' border='0' width='"+pic_width+"' height='"+pic_height+"' name='logo'>\n");

setTimeout('change_it2()',5000);
}
}

function change_it2()
{
var x=0;
thenum+=1;

if (thenum>numpics-1)
thenum=0;

document[imgName].src=pics[thenum];

x+=1;
setTimeout('change_it2()',5000);
}
//-->

</script>
</head>
<body>
<div id="wrapper">
<div id="header">

<script type="text/javascript">
<!--
change_it();
//-->
</script>
<p><strong>St. Cloud Orthopedic Associates, LTD.</strong><br />
1555 Northway Drive • (320) 259-4100<br />
St. Cloud, MN 56303</p>
</div>
</div>
</body>
</html>

the question is how do I setup the changeit() so it will work with my css so i can float it to the left and the <p> to the center?
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Add the class attribute to the img tag and specify the appropriate class from your css file.


GenRocket - Experts at Building Test Data
Tony Lavalle
Ranch Hand

Joined: Jan 18, 2005
Posts: 36
ok doing that how would i call it from the img tag?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Add the class attribute to the line document.write("<img src

Eric
Tony Lavalle
Ranch Hand

Joined: Jan 18, 2005
Posts: 36
ok got it. it works thank you both.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: A simple javascript and html quest