I have an HTML document (here), which creates an iframe-based media player for a collection of songs within albums (I just used letters to define these albums and songs in the mymusic array, for simplicity).
Focusing on the top 3 iframes, the way I have set out the user interaction is to generate the HTML for forms of available albums and songs using Javascript, and write them to the iframes in the body. If you run it and make a selection in the Albums menu, you will see that the options in the Songs menu correspond with the mymusic array, so this works.
However, when I choose a song, the function nowplaying(trackindex,albumindex) should be called using an onchange event in the Songs form, the same way as in the form generated using showinitial() … but the function does not get called.
I have ruled out the coding of nowplaying itself as a cause, because even when I change nowplaying to alert("hello"), it does not get called. So this leads me to think the problem is with the onchange attribute in “anything”, but I can’t see the problem. The way I coded it is no different to before, and that worked fine, so why won’t this work?
Any help would be much appreciated!
Firebug is your friend….
onchange is getting called, but
iis not defined when callingnowplaying.This is the result of this line:
which is using "i" in the string, when it should append it as a variable:
To clarify,
iis defined whenanything(i)is called, but you aren’t writingiinto the code, just the letter "i". Whennowplaying(this.SelectedIndex,i)is called,iis no longer defined, because you aren’t inside of theanything()function anymore. You need to expandiwhen you append the html top, so that the value is there and not the variablei.