Home > front end >  Play a sound when a certain value is selected on slider
Play a sound when a certain value is selected on slider

Time:07-11

I'm trying to make a simple slider that when choosing a certain value on it (in this case 76), the button that says "Continue" plays a certain sound instead of redirecting, but i don't seem to get it to work, could you guys help me out on this? here is the snippet.

           <div id="Slider">
        <span id="rangeValue">0</span>
        <Input  type="range" name "" value="0" min="0" max="100" onChange="rangeSlide(this.value)" onm ousemove="rangeSlide(this.value)"></Input>
    </div>
    <script type="text/javascript">
        function rangeSlide(value) {
            document.getElementById('rangeValue').innerHTML = value;
        }
    </script>
<button  id="i22w3" onclick="play()">Continue</button>
<audio id="audio" src="https://www2.cs.uic.edu/~i101/SoundFiles/BabyElephantWalk60.wav"></audio>
<script type="text/javascript">

var audio = document.getElementById("audio");
      function play() {
        if ('rangeValue' = 76) {
   audio.play();
} else {
   window.location.replace("https://example.com/");
}
        

Thank you in advance!

CodePudding user response:

Fixed a few things in the code, a couple of which could have been from forgetting to copy the bottom couple of lines

  • Related