hi everyone, i am trying to assign the sounds to my buttons. it works when the mouse is over them. the problem is that i do not want the sound to play when i touch the same button again. please help, i am a beginner with js
what if i want to play the sound again but not two times in raw? i mean to play the sound again i need to play different sound touching another button before. is there any easy way to do it?
@jayapalchandranMar 15.2009 — #Firstly, let me tell you what i understood from your query.
you have a page where you have 'n' buttons. Once a button say 'i' has been clicked then for the next click it should not work. So once it is clicked until you reload the page it should not be clicked again. and you want to apply this for all buttons which will play sound.
for that here is another silly answer
you can have as many as flag variables for each buttons like psbtn1, psbtn2, etc... and repeat the same code by changing the variable names... like the following...
<script>
var psbtnv1=psbtnv2=psbtnv3=1;
</script>
//input name='psbtn1'
onmouseover="if(psbtnv1){playsound();psbtnv1=0;}"
//input name='psbtn1'
onmouseover="if(psbtnv2){playsound();psbtnv2=0;}"
//input name='psbtn1'
onmouseover="if(psbtnv3){playsound();psbtnv3=0;}"
and then you can use your intelligence to create a robust way of using it by creating objects...
if the above code does not match your need then ping again.
@wolandtauthorMar 15.2009 — #thanks for response, but i wasn's clear with my query.
here is a script i have: [code=html] <script type="text/javascript"> function mouseOver1() { document.getElementById("b1").src ="images/tree2bb.jpg"; soundManager.play('mo'); changeimage(myimages[1]); } function mouseOver2() { document.getElementById("b2").src ="images/tree2cb.jpg"; soundManager.play('mo'); changeimage(myimages[2]); } function mouseOver3() { document.getElementById("b3").src ="images/tree2db.jpg"; soundManager.play('mo'); changeimage(myimages[3]); } </script> [/code] and i have 3 buttons with onmouseover events:
mouseOver1()
mouseOver2()
mouseOver3()
and now:
when i mouse over button 1 and the sound is played i want to disable it (soundManager.play('mo') function for button 1) for a while - until the sound from any of the other buttons (2 or 3) is played. so for instance when the soundManager.play('mo') of the button 2 is played i can again use this function for the button 1 without reloading the page.