Results 1 to 2 of 2

Thread: using variables with objects

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2000
    Posts
    31

    using variables with objects

    hi everyone, i have a drop down list and a Real player "play" button on my page, the drop down list contains the names of soundfiles,,,,,Im trying to get it so that when the user chooses a soundfile from the drop down list that they can then play it by hitting the play button....
    heres the code ive used sofar
    --------------------

    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

    <script language="JavaScript">
    <!--
    function Playsnd(){
    if (document.form1.sndselect.options[0].selected){
    var MyAddress="call_back.ram";}

    else if (document.form1.sndselect.options[1].selected)
    { var MyAddress="f11d2.ram";}

    return true;
    }

    function MM_callJS(jsStr) { //v2.0
    return eval(jsStr)
    }
    //-->
    </script>
    </head>

    <body bgcolor="#FFFFFF" text="#000000" >
    <p>&nbsp;</p>
    <form name="form1" action="" OnSelect="MM_callJS('Playsnd()')">
    <select name="sndselect" size="1">
    <option value="http://www.servecast.com/testaccounts/rams/">example 1</option>
    <option value="http://www.servecast.com/testaccounts/rams/">example 2</option>
    </select>
    </form>



    <p><object id=Audio1 classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" width=41 height=32 border="2">
    <param name="controls" value="playbutton">
    <param name="console" value="Clip1">
    <param name="autostart" value="false">
    <param name="src" value="http://www.servecast.com/testaccounts/rams/"+MyAddress>

    </object></p>
    </body>
    </html>
    -----------------------------

    It seems that the variable MyAddress doesn't contain the name of the soundfile like i hoped...
    ..value="http://www.servecast.com/testaccounts/rams/"+MyAddress>
    if anyone has any ideas i would appreciate the help.
    thanks
    Skat

  2. #2
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    Try this:
    Code:
    <script language="JavaScript">
    <!--
    var My Address;
    function Playsnd()
    {
      if (document.form1.sndselect.options[0].selected)
      {
        MyAddress="call_back.ram";
      }
      else if (document.form1.sndselect.options[1].selected)
      {
        MyAddress="f11d2.ram";
      }
      return true; 
    }
    The way you had it, the variable MyAddress was only good in the if statement. You have to declare it out of the function if you want it to be able to be used in other functions.

Posting Permissions

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



Click Here to Expand Forum to Full Width