Play a sound file on click event

I want to play a dynamically generated DTMF sound file when an icon is clicked.

I've tried the embed tag but can't get it to work.
Also I don't want any player icon / progress bar to display.
I simply want the sound to be played.

Here is an example of where I'm getting the sound file from.
http://aggemam.dk/scripts/dtmf.php?n=5551234

I'm using jquery
I tried the jquery.sound plugin but couldn't get it to work.

Thanks
Matthew_WayAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

KNVB HKSITOCommented:
1)What file format for your sound file?
2)What is your target browser(e.g. IE,firefox,chrome)?
KNVB HKSITOCommented:
what do you mean dynamically generated DTMF?
do you mean when user click on an '1' image, then it will play '1' dial tone?
KNVB HKSITOCommented:
You can browse my web site for reference.

http://www.gossipcafe.hk/application-demo/jsp-demo/putonghua/

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Michel PlungjanIT ExpertCommented:
Matthew_WayAuthor Commented:
Your example site helped me.

See code snippet for my working sample.

2 tricks.
#1 embed hidden attribute.
#2 because the file is dynamically sent need to specify type attribute.

Xie Xie
<html>
<head>
<title>Embed test</title>
</head>
<script language="javascript">
  function playSound()
   {
   	
	var numberToDial = document.getElementById('number').value;
    x=document.getElementById("sound");
	x.innerHTML='<EMBED src="http://aggemam.dk/scripts/dtmf.php?n='+numberToDial+'" type="audio/basic" hidden="true">';
   }
</script>
<body>
<input name="number" id="number" value="555 7878" />
<a href="javascript:playSound()">play DTMF</a><br />
<div id="sound">
</div>
</body>
</html>

Open in new window

Matthew_WayAuthor Commented:
@mplungjan

Thanks for you suggestion but I don't want to run java applets or flash.
Michel PlungjanIT ExpertCommented:
so do you need help now or are you happy with the working example?
KNVB HKSITOCommented:
You may try the following:
<html> 
<head> 
<title>Embed test</title> 
</head> 
<script language="javascript"> 
  function playSound(numberToDial) 
   { 
        x.innerHTML='<EMBED src="http://aggemam.dk/scripts/dtmf.php?n='+numberToDial+'" type="audio/basic" hidden="true">'; 
   } 
</script> 
<body> 
<a href="javascript:playSound(1)">1</a><br/> 
<a href="javascript:playSound(2)">2</a><br/> 
<a href="javascript:playSound(3)">3</a><br/> 
<a href="javascript:playSound(4)">4</a><br/> 
<a href="javascript:playSound(5)">5</a><br/> 
<a href="javascript:playSound(6)">6</a><br/> 
<a href="javascript:playSound(7)">7</a><br/> 
<a href="javascript:playSound(8)">8</a><br/> 
<a href="javascript:playSound(9)">9</a><br/> 
<div id="sound"> 
</div> 
</body> 
</html>

Open in new window

Michel PlungjanIT ExpertCommented:
I would for sure do this instead

<script language="javascript"> 
function playSound(numberToDial)  { 
  x.innerHTML='<EMBED src="http://aggemam.dk/scripts/dtmf.php?n='+numberToDial+'" type="audio/basic" hidden="true">'; 
  return false; // cancel link
} 
</script> 
<body> 
<a href="#" onClick="return playSound(1)">1</a><br/>

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.