Web Analytics Made Easy -
StatCounter Can't be that far off, but it refuses to execute the function - CodingForum

Announcement

Collapse
No announcement yet.

Can't be that far off, but it refuses to execute the function

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can't be that far off, but it refuses to execute the function

    My first idea was to make a drop-down menu of song titles, and use JavaScript to display the lyrics at the bottom of the page when you hit "Go." I realized then that the document.write command would eventually make all of the text appear at the bottom, and not delete the old osng lyrics when you changed. (I'd also have to code in the lyrics to the Script, as I don't know how to make JS exctract data from, say, a text or HTML file)

    So I made life simple on myself and just had it open a brand new window with the file. The menu for the song lyrics works out fine in the code below, however, when I click on the submit button for the quotes pages (which, I think, i coded the exact same way as the other), it won't run the function. My browser (IE and Mozilla both) just sit there, staring at me and calling me names (okay, not really).

    The code is below; to see the page online, go to: http://www.vyenpakakapaka.com/temporarylhq.htm

    You can see what I wanted to do wiht the page: I wanted the user to be able to listen to one of the available midi files while they browse some song lyrics or get some nifty quotes.

    Another question I have is with my Stop command: it cuases an error in IE, but it does, in fact, stop the music, and allow me to continue on as I normally would. HOwever, it does give me that evil yellow triangle in my bottom corner. It's not as big of a deal as my non-working function, however.


    In short:
    Link: http://www.vyenpakakapaka.com/temporarylhq.htm
    Problem 1: "Show Quotes" Button does nothing.
    Problem 2: "Stop the Music" link causes non-fatal error in IE (possibly other browsers)

    Code:

    Code:
    <html>
    <script language="JavaScript">
    function lyrics() {
    window.open(document.lyricform.choice.value + ".txt", "Lyrics");
    }
    function quotes() {
    window.open(document.quoteform.choice.value + ".txt", "Quotes");
    }
    function playsong(song) {
    document.embeds[song].play();
    }
    
    </script>
    <embed SRC="http://museum.vyenpakakapaka.com/midi/YourSong.mid" HIDDEN=true AUTOSTART=false>
    <embed SRC="http://museum.vyenpakakapaka.com/midi/RocktMan.mid" HIDDEN=true AUTOSTART=false>
    <embed SRC="http://museum.vyenpakakapaka.com/midi/ImpMarch.mid" HIDDEN=true AUTOSTART=false>
    <embed SRC="http://museum.vyenpakakapaka.com/midi/Hawaii50.mid" HIDDEN=true AUTOSTART=false>
    Play a song!<br>
    <form name="form01"><select NAME="song" SIZE=1>
    <option VALUE="0" SELECTED>Elton John - Your Song (MID)</option>
    <option VALUE="1" SELECTED>Elton John - Rocketman (MID)</option>
    <option VALUE="2" SELECTED>John Williams - Imperial March (MID)</option>
    <option VALUE="3" SELECTED>Unknown Artist - Hawaii 5-0 Theme</option>
    
    </select>
    <input TYPE="BUTTON" NAME="buttonofdoom" VALUE="Play" OnClick="playsong(document.form01.song.value)">
    </form>  <a href="javascript:stopSound()">Stop Sound!</a>
    <br><br>
    Show Song Lyrics:<br>
    <form name="lyricform"><select NAME="choice" SIZE=1>
    <option VALUE="ill">I'll Be - Goo Goo Dolls</option>
    </select>
    <input TYPE="BUTTON" NAME="lyricbutton" VALUE="Show Lyrics" OnClick="lyrics();">
    </form>
    <form name="quoteform">
    <select NAME=choice" SIZE=1>
    <option VALUE="love">Love Quotes</option>
    
    </select>
    <input TYPE="BUTTON" NAME="quotebutton" VALUE="Show Quotes" OnClick="quotes()">
    </form>
    </html>

    I can't for the life of me figure out what I did wrong in coding the last button. I -know- its something really silly, like a missed semicolon (BTW, i added a semicolon to the last OnClick command; the same problem occured), but I just don't see it and I just can't fix it. Someone with sharper eyes will probably pick it up right off the bat.

    EDIT and NOTE:The links the buttons are supposed to take you till probably will not work; that's okay, I realize this. But it should still give me a 404 error if the code is working right, which is my first priority. Just thougt you should know, in case that makes any difference.


    Thanks a bunch!

    "Vyenpakakapaka" Michael Quell
    http://www.vyenpakakapaka.com
    Last edited by Vyenpakakapaka; Jul 30, 2005, 04:41 PM. Reason: Err, one last thing...

  • #2
    You can't get the selected value from a select tag that way.

    Try this: (untested)
    Code:
    <script language="JavaScript">
    function lyrics() {
    window.open(getSelection(document.lyricform.choice) + ".txt", "Lyrics");
    }
    function quotes() {
    window.open(getSelection(document.quoteform.choice) + ".txt", "Quotes");
    }
    function playsong(song) {
    document.embeds[song].play();
    }
    function getSelection(select)
    {
    return select.options[select.selectedIndex].value;
    }
    </script>
    and
    Code:
    <input TYPE="BUTTON" NAME="buttonofdoom" VALUE="Play" OnClick="playsong(getSelection(document.form01.song))">
    ScriptingMagic.com

    Comment


    • #3
      geek...=P

      Works just fine for me...thanks a bunch ^^

      Comment

      Working...
      X