Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get object expected and dont know a way out of it!!!! 3

Status
Not open for further replies.

rnby

Technical User
Jan 25, 2005
8
BE
<html>
<head>
<script language="javascript">
songnumber=0;
playlist=0;
function sivamtime() {
var hour1 = 10;
var min1 = 10;
var sec1 = 10;
var straddr = "<!--#echo var="DATE_LOCAL"-->";
var sec = (straddr.charAt(straddr.length - 6) +
straddr.charAt(straddr.length - 5));
var min = (straddr.charAt(straddr.length - 9) +
straddr.charAt(straddr.length - 8));
var hour = (straddr.charAt(straddr.length - 12) +
straddr.charAt(straddr.length - 11));

document.write(""+hour+":"+min+":"+sec+"");
document.write("<br>");
document.write(""+hour1+":"+min1+":"+sec1+"");
document.write("<hr>");
document.write("<br>");

if (hour>hour1) {
newhour=hour-hour1;
} else if (hour<hour1) {
temphour=24-hour1;
temphour2=temphour-hour
if (temphour2<0) {
newhour=24+temphour2-4;
} else {
newhour=24+temphour2-4
}
} else {
newhour=0;
}
//end of hours

//start of minutes
if (min>min1) {
newmin=min-min1;
} else if (min<min1) {
tempmin1=60-min;
tempmin2=tempmin1+min1;
newmin=tempmin2-20;
} else {
newmin=0
}
//end of minutes

//start of seconds
if (sec>sec1) {
newsec=sec-sec1;
} else if (sec<sec1) {
tempsec1=60-sec;
tempsec2=tempsec1+sec1;
newsec=tempsec2-20;
} else {
newsec=0
}

document.write(newhour);
document.write(":");
document.write(newmin);
document.write(":");
document.write(newsec);
document.write("<br>");
document.write("<hr>");
document.write("<br>");

//convert total time to seconds

var tst1=newhour*1200;
var tst2=newmin*60;
var tst3=tst1+tst2;
var totalsec=tst3+newsec;
document.write(tst1);
document.write("<br>");
document.write(tst2);
document.write("<br>");
document.write(totalsec);
document.write("<hr><hr>");

//playlist with musicname and time

function music(name,length,title) {
this.name=name; this.length=length
}

var line = new Array()
line[0] = new music('muziek',5000)
line[1] = new music('muziek2',6500)
line[2] = new music('muziek3',35)
line[3] = new music('muziek',35)
line[4] = new music('muziek2',35)
line[5] = new music('muziek3',35)
line[6] = new music('muziek',35)
line[7] = new music('muziek2',15)
line[8] = new music('muziek3',30)
line[9] = new music('muziek',20)
line[10] = new music('muziek2',15)
line[11] = new music('muziek3',30)
line[12] = new music('muziek',20)
line[13] = new music('muziek2',15)
line[14] = new music('muziek3',30)
line[15] = new music('muziek',20)
line[16] = new music('muziek2',15)
line[17] = new music('muziek3',30)
line[18] = new music('muziek',20)
line[19] = new music('muziek2',15)
line[20] = new music('muziek3',30)
line[21] = new music('muziek',20)
line[22] = new music('muziek2',15)
line[23] = new music('muziek3',30)
line[24] = new music('muziek',20)
line[25] = new music('muziek2',15)
line[26] = new music('muziek3',30)
line[27] = new music('muziek',20)
line[28] = new music('muziek2',15)
line[29] = new music('muziek3',30)
line[30] = new music('muziek',20)
line[31] = new music('muziek2',15)
line[32] = new music('muziek3',30)
line[33] = new music('muziek',20)
line[34] = new music('muziek2',15)
line[35] = new music('muziek3',30)
line[36] = new music('muziek',20)
line[37] = new music('muziek2',15)
line[38] = new music('muziek3',30)
line[39] = new music('muziek',20)
line[40] = new music('muziek2',15)
var time=totalsec;
document.write(playlist+"<BR>");
document.write(songnumber+"<BR>");
document.write(time+"<BR>");

if (time > playlist) {
playlist=playlist+line[songnumber].length;
document.write(playlist+"<BR>");
++songnumber;
sivamtime()}
else {var musicsrc="[songnumber].name+".mp3";
document.write('<bgsound src="'+musicsrc+'">');
var q_songlength=line[songnumber].length*1000;
setTimeout('sivamtime()',q_songlength);
alert(songnumber);
}






}




</script>
</head>
<body onload="sivamtime()">

<script language="javascript">

</script>



</body>
</html>
 
hello, i get the whole time "object expected"
the link of the page is

I want to be able to play music and when the song finished i should go to the next song by itself. i use for that a timeout what uses the songlength. i use here the time of the server to make sure everybody gets the same song at the same time

if somebody knows how to help me, please.
 
You're missing a closing parenthesis ( on the line before alert(songnumber). If you want to debug your own JS programming, use a browser other than IE.

Lee
 
Well, I wouldn't say IE doesn't have any debugging capabilities. By itself it sucks, but if you use it with VS.NET (possibly InterDev too) you can step through the JavaScript code or break into the code when it errors. I imagine even the free Web Matrix supports that. Just my two cents..

Adam
 
Thanks everybody for answering i instlled web matrix and mozilla.
now i get a different error and dont know how to fix that??
it tells me that the function i'm using in the timeout is not defined
 
rnby,

I think it is this.
[tt]
var straddr = "<!--#echo var=[COLOR=red yellow]'[/color]DATE_LOCAL[COLOR=red yellow]'[/color]-->";
[/tt]
You should discover it if you use netscape's javascript console.

regards - tsuji
 
I usually use the single quotes in JS and double for the HTML:

var straddr = '<!--#echo var="DATE_LOCAL"-->';

Lee

 
var straddr = '<!--#echo var="DATE_LOCAL"-->';
this is in order to get the time from the server
but it's not the problem. because if I just let it display the time it works without any problems.
I think the problem is the timer.
I get the player to work and it goes wrong the moment he needs to execute the timeout
 
rnby,

I don't understand what you mean by it's not the problem. It may not be the whole problem. But after correcting this syntactic mistake, the page does display, does it not? and not being a blank with the "object expected" error. You sure have to debug why your timer(?) does not function as anticipated.

- tsuji
 
tsuji,

You'd be correct if the server never parsed the page. However, when the server replaces the SSI statement with the real date (which doesn't have quotation marks) it would no longer be the problem.

rnby,

It might help if you posted the code of the page after the server has parsed it. (Using View --> Source)

Adam
 
Never mind, I followed the link you posted. If you read the first error you get, it says
Code:
Line: 147
Char: 8
Error: Expected ')'
Code: 0
URL: [URL unfurl="true"]http://geocities.com/musicyid/lukt.html[/URL]

Which is this line:
Code:
document.write('<bgsound src='+'"'+musicsrc+'">'

Adam
 
Hi Adam,

My note is just out of sheer frustration. I take note of your remark, still need to understand the full implication. Thanks.

regards - tsuji
 
Thank you all for your answer.
first of all the time isn't the problem because the script gets the time from the server as follows
var straddr = "Friday, 28-Jan-05 08:35:13 PST";
I changed now what adam0101 told me and it starts doing weird.
so the script starts to play the song unlimited amount of times and it makes the computer crash.
so i just dont know what i do wrong that it does that.
here is the script as it's now


<html>
<head>
<script language="javascript">


function sivamtime() {
var hour1 = 10;
var min1 = 10;
var sec1 = 10;
var straddr = "<!--#echo var="DATE_LOCAL"-->";
var sec = (straddr.charAt(straddr.length - 6) +
straddr.charAt(straddr.length - 5));
var min = (straddr.charAt(straddr.length - 9) +
straddr.charAt(straddr.length - 8));
var hour = (straddr.charAt(straddr.length - 12) +
straddr.charAt(straddr.length - 11));

document.write(""+hour+":"+min+":"+sec+"");
document.write("<br>");
document.write(""+hour1+":"+min1+":"+sec1+"");
document.write("<hr>");
document.write("<br>");

if (hour>hour1) {
newhour=hour-hour1;
} else if (hour<hour1) {
temphour=24-hour1;
temphour2=temphour-hour
if (temphour2<0) {
newhour=24+temphour2-4;
} else {
newhour=24+temphour2-4
}
} else {
newhour=0;
}
//end of hours

//start of minutes
if (min>min1) {
newmin=min-min1;
} else if (min<min1) {
tempmin1=60-min;
tempmin2=tempmin1+min1;
newmin=tempmin2-20;
} else {
newmin=0
}
//end of minutes

//start of seconds
if (sec>sec1) {
newsec=sec-sec1;
} else if (sec<sec1) {
tempsec1=60-sec;
tempsec2=tempsec1+sec1;
newsec=tempsec2-20;
} else {
newsec=0
}

document.write(newhour);
document.write(":");
document.write(newmin);
document.write(":");
document.write(newsec);
document.write("<br>");
document.write("<hr>");
document.write("<br>");

//convert total time to seconds

var tst1=newhour*1200;
var tst2=newmin*60;
var tst3=tst1+tst2;
var totalsec=tst3+newsec;
document.write(tst1);
document.write("<br>");
document.write(tst2);
document.write("<br>");
document.write(totalsec);
document.write("<hr><hr>");

//playlist with musicname and time

function music(name,length,title) {
this.name=name; this.length=length
}

var line = new Array()
line[0] = new music('muziek',20)
line[1] = new music('muziek2',15)
line[2] = new music('muziek3',30)
line[3] = new music('muziek',20)
line[4] = new music('muziek2',15)
line[5] = new music('muziek3',30)
line[6] = new music('muziek',20)
line[7] = new music('muziek2',15)
line[8] = new music('muziek3',30)
line[9] = new music('muziek',20)
line[10] = new music('muziek2',15)
line[11] = new music('muziek3',30)
line[12] = new music('muziek',20)
line[13] = new music('muziek2',15)
line[14] = new music('muziek3',30)
line[15] = new music('muziek',20)
line[16] = new music('muziek2',15)
line[17] = new music('muziek3',30)
line[18] = new music('muziek',20)
line[19] = new music('muziek2',15)
line[20] = new music('muziek3',30)
line[21] = new music('muziek',20)
line[22] = new music('muziek2',15)
line[23] = new music('muziek3',30)
line[24] = new music('muziek',20)
line[25] = new music('muziek2',15)
line[26] = new music('muziek3',30)
line[27] = new music('muziek',20)
line[28] = new music('muziek2',15)
line[29] = new music('muziek3',30)
line[30] = new music('muziek',20)
line[31] = new music('muziek2',15)
line[32] = new music('muziek3',30)
line[33] = new music('muziek',20)
line[34] = new music('muziek2',15)
line[35] = new music('muziek3',30)
line[36] = new music('muziek',20)
line[37] = new music('muziek2',15)
line[38] = new music('muziek3',30)
line[39] = new music('muziek',20)
line[40] = new music('muziek2',15)
var playlist= 0;
var time=totalsec;
var songnumber=0;
document.write(playlist+"<BR>");
document.write(songnumber+"<BR>");
document.write(time+"<BR>");

while (time > playlist) {
playlist=playlist+line[songnumber].length;
document.write(playlist+"<BR>");

var musicsrc="[songnumber].name+".mp3";
document.write('<bgsound src='+'"'+musicsrc+'">')
alert(songnumber);
}

timeout1()



}

function timeout1(){
var b_songlength=line[songnumber].length;
var q_songlength=b_songlength*1000;
setTimeout('player()',q_songlength);
++songnumber;}

function player(){
var musicsrc="[songnumber].name+".mp3";
document.write('<bgsound src="'+musicsrc+'">');
alert(songnumber);
timeout1()}
//}



</script>
</head>
<body onload="sivamtime()">

<script language="javascript">

</script>



</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top