Tech Support Forum banner
Status
Not open for further replies.
1 - 6 of 6 Posts

·
Registered
Joined
·
5 Posts
Discussion Starter · #1 ·
Hi there,

I'm working on a homepage for a band in which i want to include a lyrics page that offers a list of song titles and on clicking them displays the lyrics in an extra area. Since I don't want to solve this with frames, I searched around and found this thread.

I tried to implement the code, but since the page that this topic is about doesn't exist anymore it was kind of difficult to figure it out. The more so as I do not really have much idea about javascript.

The javascript I put is
<script language="Javascript">
var lyricsArray = new Array();
lyricsArray[0] = "<p><h3>Dunkle Blumen</h3><br />Dunkle Blumen blühen, ...</p>";
lyricsArray[1] = "<h3>Time</h3><br />Have you seen...</p>";
lyricsArray[2] = "<h3>Outra Estória</h3><br />Outra estória...</p>";

function changeContent(songNo)**
var contentBox = document.getElementById("songStuff");
contentBox.innerHTML = lyricsArray[songNo];
</script>
and the body part where the lyrics are supposed to appear
<div id="songStuff" class="main">

<div class="inh_div_left">
<p><h2>Song</h2></p>
<ul>
<li><a href="#" onClick="changeContent(0)">Dunkle Blumen</a></li>
<li><a href="#" onClick="changeContent(1)">Time</a></li>
<li><a href="#" onClick="changeContent(2)">Outra Estória</a></li>
</ul>
</div>

<div class="inh_div_right"><p id="contentBox"></p></div>
</div>
Well, i tried different ways to declare the both fields as songstuff or contentbox, but nothing seems to get this working...

The whole page is here: http://www.lamento-music.com/test/en/lyrics.html

Can anybody enlight me here? :) please!
 

·
Registered
Joined
·
2,276 Posts
Hey, the problem is you've just copied what you saw, and don't know enough about JS... So to fix the problem change the "**" to a left curly brace, and before the "</script>" place a right curly brace.

Cheers,
Jamey
 

·
Registered
Joined
·
5 Posts
Discussion Starter · #3 ·
Thank you so much, Jamiemac! That did it :D.
I know it's kind of stupid to use javascript without even knowing the basics, but I'm just starting at developing. Javascript for Dummies is already on my wishlist ;).

Cheers!
 

·
Registered
Joined
·
2,276 Posts
Jumping in at the deep end is usually the best way to learn something. Immersion is the best way to learn a language. So i think you're going the right way about it, you probably want to start learning your syntax though, do that here: http://www.w3schools.com and you won't make the usual little mistakes.

Don't get JS for dummies, the book is useless! (trust me, it's the first i read and it left me stranded). Get O'Reilly's "Javascript the definitive guide", (Many say it's the only decent book on javascript and i agree).

Good luck learning.
Jamey
 

·
Registered
Joined
·
2,276 Posts
Thats k, feel free to post back with any problems you encounter.

Cheers,
Jamey
 
1 - 6 of 6 Posts
Status
Not open for further replies.
Top