Web Analytics Made Easy -
StatCounter Double combo box music selector - CodingForum


No announcement yet.

Double combo box music selector

  • Filter
  • Time
  • Show
Clear All
new posts

  • Double combo box music selector

    I have been working on a double combo box that will allow you to select media to play. You can select video, midi, or wav files from one box, and, depending on your selection, you can pick from a list of specific songs. They will be played in an <EMBED> in an <iframe> via codes from Javascriptkit , myself, and Liorean. The code goes as follows:

    <script type="text/javascript">
    function dip() {
    var it=document.doublecombo.stage2.options[document.doublecombo.stage2.selectedIndex].value;
    alert('You chose '+it+' .');
    var oIFrame = document.getElementById('i'),
     oFramedDoc = typeof oIFrame.contentDocument != 'undefined'?
     oIFrame.contentDocument: // W3C way
     typeof oIFrame.contentWindow != 'undefined'?
     oIFrame.contentWindow.document: // Microsoft way
     typeof oIFrame.document != 'undefined'?
     oIFrame.document: // Traditional way
     null; // And no way.
     if(oFramedDoc != null){
     oFramedDoc.write('o   <embed src="'+it+'" autostart="false" loop="false" volume="50%" height="245" width="185" align=CENTER> i'); } 
    </head><body bgcolor=royalblue>
    <iframe id="i"></iframe>
    <input type="button" value="DooIt" onClick="dip()">
    <form name="doublecombo">
    <p><select name="example" size="1" onChange="redirect(this.options.selectedIndex)">
    <select name="stage2" size="1">
    <option value="songURL">SONG</option>
    <option value="songURL">SONG</option>
    <option value="songURL">SONG</option>
    Double Combo Script Credit
    By JavaScript Kit ([url]www.javascriptkit.com[/url])
    Over 200+ free JavaScripts here!
    var groups=document.doublecombo.example.options.length
    var group=new Array(groups)
    for (i=0; i<groups; i++)
    group[i]=new Array()
    group[0][0]=new Option("JavaScript Kit","http://javascriptkit.com")
    group[0][1]=new Option("SONG","songURL")
    group[0][2]=new Option("SONG","songURL")
    group[1][0]=new Option("SONG","songURL")
    group[1][1]=new Option("SONG","songURL")
    group[2][0]=new Option("SONG","songURL")
    group[2][1]=new Option("SONG","songURL")
    group[2][2]=new Option("SONG","songURL")
    group[2][3]=new Option("SONG","songURL")
    var temp=document.doublecombo.stage2
    function redirect(x){
    for (m=temp.options.length-1;m>0;m--)
    for (i=0;i<group[x].length;i++){
    temp.options[i]=new Option(group[x][i].text,group[x][i].value)
    <a href="links1.html">Backc</a>
    any ideas?
    Oh, was I supposed to put something here? ........

  • #2
    So what's your question?
    vBulletin Mods That Rock!


    • #3
      Oh, woops. Um, bascially what is the problem? The thing is the 2 scripts shown work seperatly, but when combined, conflict. I can't figure out why.
      Oh, was I supposed to put something here? ........


      • #4
        Try changing the iframe name from "i" to a more descriptive name. I think it conflicts with your "i" variable.
        vBulletin Mods That Rock!


        • #5
          I changed it to "theWindow" where it was needed but it didn't work.
          Oh, was I supposed to put something here? ........


          • #6
            I tested your posted code in IE6 and the for loop

            for (i=0; i<groups; i++)

            didn't iterate because the "i" conflicts with the iframe "i" which makes the "i" an object.

            I rename the iframe to a descriptive and useful name and it worked.

            There's another solution to it without renaming the iframe.
            Put the var keyword before the "i" in the for loop

            for (var i=0; i<groups; i++)

            That makes the "i" a variable not an iframe object. Remember that IE makes all named and id'ed elements as global objects.

            But it's really recommended to use descriptive and useful names.
            vBulletin Mods That Rock!


            • #7
              YOU ROCK!!!

              It worked!!!!! Thanks!!
              Oh, was I supposed to put something here? ........