Click to See Complete Forum and Search --> : JavaScipr Help (Real Newbie :))


Leav
09-13-2003, 10:54 AM
Hi all i was wondering if you could tell me whats wron with this:

<html>
<head>
<title>Leav's HomePage</title>
<script language="JavaScript">
<!-- hide from old browsers
function openMovie(url) {
var form = document.songs;
var index = form.songList.selectedIndex;
var url = form.songList.options.index;
windOptions = "toolbar=0,location=0,directories=0,status=0," +

"menubar=0,scrollbars=0,resizable=0,width=100,height=40";
moviewin = window.open(url , "music", windOptions);
moviewin.focus();
}
// -->
</script>
</head>
<BODY bgcolor="#000000" text="#228FFF" link="#228FFF" vlink="#228FFF" alink="#FF0000">
<style>
BODY{
scrollbar-arrow-color: #606060;
scrollbar-3dlight-color: #4E4E4E;
scrollbar-highlight-color: #000000;
scrollbar-face-color: #4E4E4E;
scrollbar-shadow-color: #000000;
scrollbar-darkshadow-color: #4E4E4E;
scrollbar-track-color: #000000;
}
</style>

<!--<a href="javascript:openMovie('http://www28.brinkster.com/leav/midis/wamdue.mid')">Movie1</a><BR>
<a href="javascript:openMovie('HugeMovie2.htm')">Movie2</a><BR>
<a href="javascript:openMovie('HugeMovie2.htm')">Movie3</a>-->
<form name="songs">
<select name="songList">
<option value="http://www28.brinkster.com/leav/midis/wamdue.mid">Wamdue Project
<option value="http://www28.brinkster.com/leav/midis/greenday.mid">Minority
<option value="http://www28.brinkster.com/leav/midis/simpsons.mid">Simpsons Theme
<input type="button" value="Play!" onClick="javascript:openMovie()">
</select>
</form>

</body>
</html>




its supposed to be a midi player with a drop down box selector but it doesnt work right (i get a 404) and i dont think the problem is with the URL.


Thanks,
Leav


(edited to disable smilies)

Jupac
09-13-2003, 10:59 AM
you have 2 url in the function and a var

Leav
09-13-2003, 11:35 AM
this is how it look now:
(sorry for the spamming :( )


<html>
<head>
<title>Leav's HomePage</title>
<script language="JavaScript">
<!-- hide from old browsers
function openMovie(url) {
var form = document.songs;
var index = form.songList.selectedIndex;
var songname = form.songList.options[index];
windOptions = "toolbar=0,location=0,directories=0,status=0," +
"menubar=0,scrollbars=0,resizable=0,width=100,height=40";
moviewin = window.open(songname , "movie", windOptions);
moviewin.focus();
}
// -->
</script>
</head>
<BODY bgcolor="#000000" text="#228FFF" link="#228FFF" vlink="#228FFF" alink="#FF0000">
<style>
BODY{
scrollbar-arrow-color: #606060;
scrollbar-3dlight-color: #4E4E4E;
scrollbar-highlight-color: #000000;
scrollbar-face-color: #4E4E4E;
scrollbar-shadow-color: #000000;
scrollbar-darkshadow-color: #4E4E4E;
scrollbar-track-color: #000000;
}
</style>
<form name="songs">
<select name="songList">
<option value="http://www28.brinkster.com/leav/midis/wamdue.mid">Wamdue Project
<option value="http://www28.brinkster.com/leav/midis/greenday.mid">Minority
<option value="http://www28.brinkster.com/leav/midis/simpsons.mid">Simpsons Theme
<input type="button" value="Play!" onClick="javascript:openMovie()">
</select>
</form>

</body>
</html>




So:
1)when the button is pressed and openMovie() is triggerd then what happens in the head? that is: what is received by the function and what is that var's name?
(i think it isnt getting the midi's name right).

2)i checked the properties of the new window that was popped up: it says "http://www28.brinkster.com/leav/udefined" what is that? i dont have that folder, nor is it specified anywhere in the code.


thanks for reading ,
Leav

Jupac
09-13-2003, 11:55 AM
<script type="text/javascript">
function open(win){
if (win == 1){window.open("mid1.mid");}
if (win == 2){window.open("mid2.mid");}
if (win == 3){window.open("mid3.mid");}
if (win == 4){window.open("mid4.mid");}

else{
document.write("cant find it lol");
}
}
</script>
and use
javascript:open(1);
or onclick open(1);

Leav
09-13-2003, 12:17 PM
ok so using tricks from C++ and Pascal i narrowed down the wrror to the the following areas:

function openMovie(url) {
var form = document.songs;
var index = form.songList.selectedIndex;
var songname = form.songList.options[index];

OR

<form name="songs">
<select name="songList">
<option value="http://www28.brinkster.com/leav/midis/wamdue.mid">Wamdue Project
<option value="http://www28.brinkster.com/leav/midis/greenday.mid">Minority
<option value="http://www28.brinkster.com/leav/midis/simpsons.mid">Simpsons Theme
<input type="button" value="Play!" onClick="javascript:openMovie()">
</select>
</form>


it seems that the problem is probabley in the function and the "var <varname> =" part in particulear.

Please try to help,
Leav

Leav
09-13-2003, 12:22 PM
does that work with a drop down menu?
should i just replace my old function and it should work?

Leav
09-13-2003, 12:46 PM
http://www28.brinkster.com/leav/midiplayer.html

please take a look at that page, i'm going to sleep now because i have school tommorow.

i added a document.write(songname); so we can see what value its passing to the window.open

it seems that its always this "[object]" (no " but with [ ) which sucks cause its supposed to be a URL....


ZzZzZzZzZzZzZzZzZzZzZzZzZzZ

David Harrison
09-13-2003, 03:28 PM
Change this line:

var songname = form.songList.options[index];

to this:

var songname = form.songList.options[index].value;

That should make it work.

Leav
09-13-2003, 04:42 PM
IT WORKS!!!!!!!!
THANK YOU LAVALAMP!!!!!!!!

and like all other people i have become greedy....
can i make the song play in a frame (with a target specified).


again thank you lavalamp...!!!!! :D
(and ofcourse everybody else!!!)
you are :cool: !!!!!!

David Harrison
09-13-2003, 05:36 PM
I've attached a script that makes the location of the frame as the same location of the midi file, however I suggest that you create a separate .html page for each midi file and embed the file into it. Anyway here's the current script:

Leav
09-13-2003, 11:57 PM
*Bows Down To The Master Of Java Script*

*bow*

*looks for bow down animation on google*
*kicks computer when he doesnt find one*

*bow down*



and seariousley, thanks man....:D

i can learn alot from that script and i intend to
i know that was probabley the easiest thing you ever did but thanks anyway.


and now, something completley diffrent,

PLUGGING MY SITE!!!! (with the new and improved midi player)

http://www28.brinkster.com/leav/

lavalamp do you have a site?
sites are a good way to spend your time when your supposed to be doing homework (unless you try to use javascript and you dont klnow javascript and you always get these error messeges and since you only know C++ you dont get anything working right and you have no idea why var's have dots in them and wtf is that [index] thing and are all vars global vars and if so why not write everything in the body???!!!!!!!!)

Leav
09-13-2003, 11:57 PM
*Bows Down To The Master Of Java Script*

*bow*

*looks for bow down animation on google*
*kicks computer when he doesnt find one*

*bow down*



and seariousley, thanks man....:D

i can learn alot from that script and i intend to
i know that was probabley the easiest thing you ever did but thanks anyway.


and now, something completley diffrent,

PLUGGING MY SITE!!!! (with the new and improved midi player)

http://www28.brinkster.com/leav/

lavalamp do you have a site?
sites are a good way to spend your time when your supposed to be doing homework (unless you try to use javascript and you dont klnow javascript and you always get these error messeges and since you only know C++ you dont get anything working right and you have no idea why var's have dots in them and wtf is that [index] thing and are all vars global vars and if so why not write everything in the body???!!!!!!!!)

David Harrison
09-14-2003, 07:08 AM
Yeah I've got a web-site (or two).

There's this (http://www.geocities.com/caulolli/) one, which I designed for someone, with minimal content. That picture is not of me by the way.

But my masterpiece (http://www.websamba.com/testorg/) is the one I'm currently still in the process of making, it's the first one that uses a server side language, ASP. It's got a really crap design but that's not the point, it's got, (apart from 1 thing which I'm gonna fix), valid XHTML 1.1, valid CSS and conforms to the WCAG (http://www.w3.org/TR/WAI-WEBCONTENT/).

By the way I like your "Leav's Home Page" image.

Happy to help. :)

Leav
09-14-2003, 11:41 PM
Hi man first of all thanks for looking at my site.

and comments on your websites:

1)ROFLMAO!!!!!!!!!!!!!!!!!!!!!! lol look at that guy!!!!!!!!!!!!

2)404 so i cant look at it, maybe you should get a temp up so people at least know that there IS a site there.


Cool man , cya later

Leav
09-14-2003, 11:43 PM
Oh And about the logo:

do you want one?
i can make one in a second.

David Harrison
09-15-2003, 03:46 AM
Hmm, I'm a bit worried about my site being down, it shouldn't be. I'll have to go away and think about that.

Thanks for the offer about the logo and all, but I'll pass. The site I'm working on is geared towards, "helping budding web-designers", presentation is kind of secondary, (which is a good think beause I'm not very good at presenting).

I'm just happy to help. :)