This week's book giveaway is in the General Computing forum.
We're giving away four copies of Learning Regular Expressions and have Ben Forta on-line!
See this thread for details.
Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

A simple javascript and html quest  RSS feed

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add the class attribute to the img tag and specify the appropriate class from your css file.
 
Tony Lavalle
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok doing that how would i call it from the img tag?
 
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add the class attribute to the line document.write("<img src

Eric
 
Tony Lavalle
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok got it. it works thank you both.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!