Forum Moderators: open
Help!
<HTML>
<HEAD>
<TITLE>Show Photo</TITLE>
<SCRIPT type="text/javascript">
var photo=new Array("000.jpg");
function showPhoto()
{
var photo=document.getElementById('000.jpg');
photo.style.cssText="display:block;";
}
</SCRIPT>
</HEAD>
<BODY>
<div id="show_photo"><input type="button" onClick="showPhoto();" value="Show Photo"></div>
</BODY>
</HTML>
What you did above: created an array containing the "000.jpg" text, in the function you declared another variable, which should be any element from within the body which has the 000.jpg ID, and when this function is called, the above elements' read/write, display property should be block.
The problem is that you don't elements with 000.jpg ID and even if you'd have, they wouldn't do anything if you fire the function by click. Also, cssText should be applied only on texts as the name suggests. You know, cssText like css-TEXT. Accent on text.
Here's this. Try it, might work ;) :
<HTML>
<HEAD>
<TITLE>Show Photo</TITLE>
<SCRIPT type="text/javascript">
function showPhoto()
{
var photo=document.getElementById('thimage');
photo.style.display="block";
}
</SCRIPT>
</HEAD>
<BODY>
<div id="thimage" style="display:none;"><img src="PUT_HERE_A_LINK_TO_AN_IMAGE" alt="blah"/></div>
<input type="button" onClick="showPhoto();" value="Show Photo">
</BODY>
</HTML>
Replace the PUT_HERE_A_LINK_TO_AN_IMAGE to a fully qualified link like [searchengineworld.com...]
Sorry for the sarcasm from the beginning, it was a must :)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Slide Show</title>
<script type="text/javascript">
var images = new Array ('aerosmith.png','alanis.png','avril_lavigne.png');
var captions = new Array ('Areosmith', 'Alanis M.', 'Avril Lavigne');
var currMark = 0;
function showImage() {
var container = document.getElementById('myContainer');
container.style.display='block';
document.getElementById('myImage').src='images\/'+images[currMark];
document.getElementById('cssText').innerHTML=captions[currMark];
document.getElementById('myButton').value=((currMark+1)>=images.length)?'First Image':'Next Image >>';
currMark=((currMark+1)>=images.length)?0:currMark+1;
}
</script>
</head>
<body>
<form style="text-align:center;" action="">
<div id="myContainer" style="display: none;"><img src="" id="myImage" alt=""></div>
<p id="cssText"></p>
<input type="button" id="myButton" onClick="showImage();" value="Show Image">
</form>
</body>
</html>
[edited by: rocknbil at 3:47 pm (utc) on Jan. 11, 2009]