Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jan 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    choosing a sound to play from a drop down box?? please help!!

    if any one can help me with this problem I would be so grateful as Ive been stuck on it for over a week now ....

    basically i want the user to select a file from a drop down box and then this will then pass the file name to the player which takes in filename as one its parameters...
    i know the update needs to assigned to an onChange() handler but i dont know how to access the <objects> parameters....

    heres my code.. ive tried writing a function which returns the string in the drop down box but i dont know how to pass it to the the objects parameters... ...

    like i mentioned b4 , im really stuck and would appreciate any help offered.....

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html><head>
    <script language="JavaScript">
    <!--

    function changeFile(the_file)
    {
    var the_url = the file;
    return the_url;

    /*This is just returning a value but I
    * want it to update the parameter "FileName" value
    * to the item in the drop down box
    */
    }
    //-->
    </script>
    </head>
    <body>

    <h2>Playing The Object</h2>
    <form name="the_form">
    <select name="choose_file"
    onChange="changeFile(window.document.the_form.choose_file.
    options[selectedIndex].text);">
    <option selected>loop1.wav
    <option>loop2.wav
    </select><BR><BR><BR>

    <object height="13.5%" width="25%" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" >
    <param name="AutoStart" value="1" />
    <param name="FileName" value="loop1.wav" />
    // How do I access this value parameter above??

    </object>
    </body>

    <script language="JavaScript">
    <!--
    window.open = SymRealWinOpen;
    //-->
    </script>
    </html>

    thanks

    mark

  • #2
    Regular Coder Vincent Puglia's Avatar
    Join Date
    Jul 2003
    Location
    where the World once stood
    Posts
    367
    Thanks
    0
    Thanked 13 Times in 13 Posts
    Hi,

    1) give the object an id so that you can reference it
    2) using the passed parameter change the value of the FileName parameter
    3) change your select statement so that the first option is a 'holder' -- otherwise, the user will never be able to select the first sound without selecting something else first (since there wouldn't be a 'change')
    4) close your option tags

    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <
    html><head>
    <
    script language="JavaScript">
    <!-- 

    function 
    changeFile(the_file)
    {
    document.getElementById('thePlayer').FileName the_file;
    }
    //-->
    </script>
    </head>
    <body>

    <h2>Playing The Object</h2>
    <form name="the_form">
    <select name="choose_file" 
    onChange="changeFile(this.options[selectedIndex].value);">
    <option value="" selected>Select a Sound</option>
    <option value='old\DoorOpen.wav' selected>open</option>
    <option value='old\DoorClose.wav'>close</option>
    </select><BR><BR><BR>

    <object height="13.5%" width="25%" id='thePlayer' classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95">
    <param name="AutoStart" value="1" />
    <param name="FileName" value ='' />
    </object>

    </body>

    </html> 
    Vinny
    Where the world once stood
    the blades of grass
    cut me still

  • #3
    New to the CF scene
    Join Date
    Jan 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hey thanks so much for that .... its been stressing me so much!

    mark

  • #4
    Regular Coder
    Join Date
    Nov 2003
    Location
    Code Heaven
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Isn't there another way of playing sounds when a user clicks a link or somethin,I remember some dude from JavaScriptKit did it,and didn't use The Windows Media Player ActiveX Control,can anyone (pretty please) post the link to that ... ?

  • #5
    Regular Coder
    Join Date
    Nov 2003
    Location
    Code Heaven
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oh,just found it,note that this is the cross-browser approach:
    http://www.javascriptkit.com/script/...oundlink.shtml


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •