Results 1 to 3 of 3

Thread: Help i'm really stuck.

  1. #1
    Join Date
    Apr 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help i'm really stuck.

    I'm new to javascript and dom, and i'm trying to make an offline jukebox player. I have used arrays to store the songs and onclick functions to play and stop songs. but none of the song names show on up in the browser when i run it. can anyone help?

    HTML Code:
    <!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>JukeBox V1.0</title>
    
    <script type="text/javascript">	
    
    	function new_song(sN, fN){
    
    		this.songName = sN;
    
    		this.fileName = fN;
    
    		}
    
    	
    
    	var album1 = new Array(5);
    
    	album1[0] = new new_song("I Will remember", "albertlucj/iwillremember.wav");
    
    	album1[1] = new new_song("Life Has Begun","albertluck/lifehasbegun.mp3 ");
    
    	album1[2] = new new_song("Valentine", "albertluck/Valentine.mp3");
    
    	album1[3] = new new_song("Time of Your Life", "albertluck/timeofyourlife.mp3");
    
    	album1[4] = new new_song("Yesterday", "albertluck/yesterday.mp3");
    
    
    
    	
    
    	/*Repeat chunk for new album*/
    
    	
    
    	function checkPlay(){
    
    		var ppb = document.getElementById("ppbutton");
    
    		if(ppb.value != 'Play'){
    
    			ppb.value = 'Play'
    
    			}
    
    		}
    
    	
    
    	function playpause(){
    
    		var songCurrent = document.getElementById("playerOb");
    
    		var ppb = document.getElementById("ppbutton");
    
    		
    
    		if(ppb.value == 'Play'){
    
    			songCurrent.controls.play();
    
    			ppb.value = 'Pause';
    
    		} else{
    
    			songCurrent.controls.pause();
    
    			ppb.value = 'Play';
    
    		}
    
    		}
    
    		
    
    	function stopSong(){
    
    		var songCurrent = document.getElementById("playerOb");
    
    		songCurrent.controls.stop();
    
    		checkPlay();
    
    		}
    
    		
    
    	function playSong(aN,sN){
    
    		checkPlay();
    
    		
    
    		var songLoc;
    
    		
    
    		switch(aN){
    
    		case 1: songLoc = album1[sN]; break;
    
    		case 2: songLoc = album2[sN]; break;
    
    		case 3: songLoc = album3[sN]; break;
    
    		}
    
    		
    
    		var songName = songLoc.songName;
    
    		var fileName = songLoc.fileName;
    
    		
    
    		var writeTest = document.getElementById("testwrite");
    
    		writeTest.firstChild.nodeValue = "fileName: "+fileName+" \n";
    
    		
    
    		/*Write in the song name*/
    
    		var writeName = document.getElementById("songNameH");
    
    		writeName.firstChild.nodeValue = "Name: "+songNameH+" \n";
    
    		
    
    		/*add the song to be played*/
    
    		var playelem = document.getElementById("playerDiv");
    
    		playelem.innerHTML = '<object id="playerOb" width="0" height="0" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">'
    
      							 +'<param name="autoStart" value="false">'
    
      					         +'<param name="URL" value="'+fileName+'">'
    
    				             +'</object>';
    
    		}
    
    		
    
    		
    
    	function song(num){
    
    		var elem = document.getElementById("testwrite");
    
    		elem.firstChild.nodeValue = "Num value = "+num+".";
    
    		}
    
    		
    
    	function loader(num){
    
    		
    
    		}
    
    </script>
    
    </head>
    
    
    
    <body>
    
    <div id="body">
    
    	<div id="content">
    
    		<div id="header" class="width100">
    
    		JukeBox V1.0
    
    		</div>
    
    		<div id="column1" class="floatleft width25">
    
    			<div class="group">
    
    				<div id="groupname" onclick="Effect.toggle('album1','slide')">
    
    				Albert Luck
    
    				</div>
    
    				
    
    				<div id="album1" style="display:none;">
    
    				<a href="#" onclick="playSong(1,0)">I will Remember</a><br />				
    
    				<a href="#" onclick="playSong(1,1)">Life Has Begun</a><br />
    
    				<a href="#" onclick="playSong(1,2)">Valentine</a><br />
    
    				<a href="#" onclick="playSong(1,3)">Time of Your Life</a><br />
    
    			    <a href="#" onclick="playSong(1,4)">Yesterday</a><br />
    
    				</div>
    
    			</div>
    
    			
    
    		
    
    			
    
    		
    
    		<div id="column2" class="floatright width73">
    
    		<div id="testwrite">fileName:</div>
    
    			<div id="songNameH">Name:</div>
    
    			
    
    			<div id="playerDiv">
    
    				
    
    
    
    			</div>
    
    			<br />
    
    			<input type="button" value="Play" onclick="playpause()" id="ppbutton" />
    
    			<input type="button" value="Stop" onclick="stopSong()" />	
    
    
    
    		</div>
    
    	</div>
    
    </div>
    
    
    
    </body>
    
    </html>
    Last edited by tech_support; 04-17-2007 at 09:06 AM. Reason: Added [html] tags.

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Try on this line:

    Code:
    writeName.firstChild.nodeValue = "Name: "+songNameH+" \n";
    change the songNameH to just songName, like so:

    Code:
    writeName.firstChild.nodeValue = "Name: "+songName+" \n";
    Explaination: The variable "songNameH" was not defined in the script (I assume you just typed in the "H" at the end because of the line right before it). The variable "songName"; however, was defined.

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Also, this script is IE-only, yet you use XHTML, which IE doesn't support. You'd be better off using HTML.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •