SlowAsChristmas
Jun 15th 2007, 5:17 pm
I am trying to adapt some code to highlight certain parts of the text. Here is what I am working with:
<script type="text/javascript">
function showPic(myPic) {
var source = myPic.getAttribute("href");
var placeholder = document.getElementById("placeholder");
placeholder.setAttribute("src",source);
var text = myPic.getAttribute("title");
var description = document.getElementById("description");
description.firstChild.nodeValue = text;
}
</script>
</head>
<body>
<h1>gallery1.htm</h1>
<ul>
<li>
<a href="images/fireworks.jpg" title="A fireworks display" onclick="showPic(this); return false;">Fireworks</a>
</li>
<li>
<a href="images/coffee.jpg" title="A cup of black coffee" onclick="showPic(this); return false;">Coffee</a>
</li>
<li>
<a href="images/rose.jpg" title="A red, red rose" onclick="showPic(this); return false;">Rose</a>
</li>
<li>
<a href="images/bigben.jpg" title="The famous clock" onclick="showPic(this); return false;">Big Ben</a>
</li>
</ul>
<img id="placeholder" src="images/placeholder.gif" alt="my image gallery" />
<p id="description">Click an image!</p>
</body>
</html>
So the text is being taken from the title attribute. I need to use more text, like some lines from a play, and want it to be pre-formatted. Is there a way to format text in the title attribute? Or is there a better way to grab the text from a different place? Basically I would like a few short lines of a play to be displayed under the image instead of just a short description. Also I need the lines of the different actors to be highlighted in some way when they are selected. Any ideas would be huge help, just a beginner. Point me in the right direction please.
<script type="text/javascript">
function showPic(myPic) {
var source = myPic.getAttribute("href");
var placeholder = document.getElementById("placeholder");
placeholder.setAttribute("src",source);
var text = myPic.getAttribute("title");
var description = document.getElementById("description");
description.firstChild.nodeValue = text;
}
</script>
</head>
<body>
<h1>gallery1.htm</h1>
<ul>
<li>
<a href="images/fireworks.jpg" title="A fireworks display" onclick="showPic(this); return false;">Fireworks</a>
</li>
<li>
<a href="images/coffee.jpg" title="A cup of black coffee" onclick="showPic(this); return false;">Coffee</a>
</li>
<li>
<a href="images/rose.jpg" title="A red, red rose" onclick="showPic(this); return false;">Rose</a>
</li>
<li>
<a href="images/bigben.jpg" title="The famous clock" onclick="showPic(this); return false;">Big Ben</a>
</li>
</ul>
<img id="placeholder" src="images/placeholder.gif" alt="my image gallery" />
<p id="description">Click an image!</p>
</body>
</html>
So the text is being taken from the title attribute. I need to use more text, like some lines from a play, and want it to be pre-formatted. Is there a way to format text in the title attribute? Or is there a better way to grab the text from a different place? Basically I would like a few short lines of a play to be displayed under the image instead of just a short description. Also I need the lines of the different actors to be highlighted in some way when they are selected. Any ideas would be huge help, just a beginner. Point me in the right direction please.