Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Search results

  1. Annabelle5893

    Playing Audio Using Keystrokes: Is It Possible?

    Here's an error I've never got before. Something about an "Uncaught Type Error". It says, "document.getElementById(...) is null", which is something I'm confused about. It also says something about "<anonymous>". I'm confused!
  2. Annabelle5893

    Playing Audio Using Keystrokes: Is It Possible?

    What shall I do next?
  3. Annabelle5893

    Playing Audio Using Keystrokes: Is It Possible?

    How's this one? <script> var hookSwitch = document.querySelector('button.hookSwitch'); var hookStatus = document.querySelector('span.hookStatus'); hookStatus.addEventListener("click", function(){ if ( hookStatus.classlist.contains('off') ){ //remove 'off' class...
  4. Annabelle5893

    Playing Audio Using Keystrokes: Is It Possible?

    How's this look to you? <script> var hookSwitch = document.querySelector('button.hookSwitch'); hookStatus.addEventListener("click", function(){ var hookStatus = document.querySelector('span.hookStatus'); if ( hookStatus.classlist.contains('off') ){ //remove 'off' class...
  5. Annabelle5893

    Playing Audio Using Keystrokes: Is It Possible?

    So I'm guessing I should put it like this? var hookStatus = document.querySelector('span.hookStatus'); if ( hookStatus.classlist.contains('off') ){ //remove 'off' class hookStatus.classlist.remove('off'); //add 'on' class hookStatus.classlist.add('on')...
  6. Annabelle5893

    Playing Audio Using Keystrokes: Is It Possible?

    Sort of. So the definitions should be outside the event listener and in a function? I'm confused!
  7. Annabelle5893

    Playing Audio Using Keystrokes: Is It Possible?

    Isn't the status defined in the "if" statements? 😕
  8. Annabelle5893

    Playing Audio Using Keystrokes: Is It Possible?

    Now I get this crazy error that says "Hook Status not defined" on line 69:1. Here's the code for the Hook Status. Why would it say the status is not defined? //grab the button 'hookSwitch' var hookSwitch = document.querySelector('button.hookSwitch'); //create an event listener for a click...
  9. Annabelle5893

    Playing Audio Using Keystrokes: Is It Possible?

    How's this version? case "*57": var randNum57=Math.random()>=0.5; if(randNum57) { var pickupCallTrace=new Audio('callResponses/trace3-xxx-fleet.mp3'); } else { var pickupCallTrace=new...
  10. Annabelle5893

    Playing Audio Using Keystrokes: Is It Possible?

    Now that I've deleted those "if" statements, what shall I do next?
  11. Annabelle5893

    Playing Audio Using Keystrokes: Is It Possible?

    So these are the ones I should delete? //default check for true if( isTrue ){ } //manual check for true if( isTrue == true ){ } //checks for the opposite of default if( !isTrue ){ } //manual check for false if( isTrue == false){ }
  12. Annabelle5893

    Playing Audio Using Keystrokes: Is It Possible?

    Are you thinking of these ones? //manual check for true if( isTrue == true ){ } //checks for the opposite of default if( !isTrue ){ } //manual check for false if( isTrue == false){ }
  13. Annabelle5893

    Playing Audio Using Keystrokes: Is It Possible?

    How's this version? <script> //grab the button 'hookSwitch' var hookSwitch = document.querySelector('button.hookSwitch'); //create an event listener for a click event hookStatus.addEventListener("onclick", function(){ //inside of the callback function for click event listener, add the...
  14. Annabelle5893

    Playing Audio Using Keystrokes: Is It Possible?

    How's this version? <script> //grab the button 'hookSwitch' var hookSwitch = document.querySelector('button.hookSwitch'); //create an event listener for a click event hookStatus.addEventListener("onclick", function(){ //inside of the callback function for click event listener, add the...
  15. Annabelle5893

    Playing Audio Using Keystrokes: Is It Possible?

    Will this allow the sounds to play when designated keystrokes are pressed?
  16. Annabelle5893

    Playing Audio Using Keystrokes: Is It Possible?

    How's this one look? case "police": var pickupPolice=new Audio('callResponses/policePickup.wav'); pickupPolice.addEventListener("click", function() { timeoutHowler(); pickupPolice.play(); var...
  17. Annabelle5893

    Playing Audio Using Keystrokes: Is It Possible?

    How does this look to you? <script> //grab the button 'hookSwitch' var hookSwitch = document.querySelector('button.hookSwitch'); //create an event listener for a click event hookStatus.addEventListener("onclick", function(){ //inside of the callback function for click event listener, add...
  18. Annabelle5893

    Playing Audio Using Keystrokes: Is It Possible?

    How's this look? case "police": var pickupPolice=new Audio('callResponses/policePickup.wav'); pickupPolice.addEventListener("click", function() { timeoutHowler(); pickupPolice.play(); var...
  19. Annabelle5893

    Playing Audio Using Keystrokes: Is It Possible?

    Will this allow the sounds to play when designated keystrokes are pressed?
  20. Annabelle5893

    Playing Audio Using Keystrokes: Is It Possible?

    Is this how all the case statements should look?
Back
Top Bottom