Button Programming Difficulties (New to JS)

I've been attempting to place this code within my game however it seems to not work. It works in code testing systems, though. Is there a conflict within the game?

<input onclick="musicToggleOn()" type="button" value="On" id="idOn"><input onclick="musicToggleOff()" type="button" value="Off" id="idOff" disabled>
<script>
    var music = false
    var buttonOn = document.getElementById('idOn');
    var buttonOff = document.getElementById('idOff');

    function testMusic() {
        if (music == true) {
            buttonOn.disabled = true;
            buttonOff.removeAttribute('disabled');
        } else {
            buttonOn.removeAttribute('disabled');
            buttonOff.disabled = true;
        }
    }

    function musicToggleOn() {
        music = true
        testMusic();
    }

    function musicToggleOff() {
        music = false
        testMusic();
    }

</script>

Log in to post a reply.

Support

Forums