Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML Drop Down Menu. 1

Status
Not open for further replies.

DM3

Technical User
Jul 3, 2003
2
US
Hello everyone,

I had a question regarding html Drop Down Menu's.

When using Drop Down Menu's, is it possible to select one of the links from that menu to play a music file?

If so - what would be the coding involved to perform that action?

Any help would be appreciated.

Thank you.
 
Yes, you would need a script in the <head> section of your page:
Code:
<script>
function playSound(sndsrc){
 document.getElementById('thesound').src = sndsrc;
}
</script>
Then you need a <bgsound> tag in the <body> of your document:
Code:
<bgsound id=&quot;thesound&quot; src=&quot;#&quot; loop=1>
And also a HTML select box with the source files and descriptions like so:
Code:
<select name=&quot;soundlist&quot; onChange=&quot;playSound(this.options[selectedIndex].value)&quot;>
  <option value=&quot;monkey.wav&quot;>monkey</option>
  <option value=&quot;organ.wav&quot;>organ</option>
  <option value=&quot;scream.wav&quot;>scream</option>
</select>
 
Thank you Dwarfthrower! That helped.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top