agiacosa
01-23-2006, 04:28 PM
Hi everyone,
I need some help from a Javascript expert. I want to give users the option of turning on and off a background sound file. I need it to be off by default.
This is the code I have so far and it works except for the default. It is defaulting to on as opposed to off.
<BODY>
<BGSOUND id=BGSOUND_CTRL src="water.mp3">
<script type="text/javascript">
var flip = "Stop Ambiance";
function toggle() {
if (flip == "Stop Ambiance") {
flip = "Start Ambiance";
document.all['BGSOUND_CTRL'].src=""
str ='<input name="dUit" type="button" value="Start Ambiance" ';
str+='class="midCtrl" onclick="toggle();">';
document.getElementById('midCtrl').innerHTML=str;
}
else {
flip = "Stop Ambiance";
document.all['BGSOUND_CTRL'].src="water.mp3"
str ='<input name="dUit" type="button" value="Stop Ambiance"';
str+='class="midCtrl" onclick="toggle();">';
document.getElementById('midCtrl').innerHTML=str;
}
}
</script>
<div id="midCtrl" class="midCtrl">
<input name="dUit" type="button" class="midCtrl" value="Stop Ambiance" onclick="toggle();">
</div>
Does anyone know how I need to change this so that the default is OFF?
Thanks in advance!
I need some help from a Javascript expert. I want to give users the option of turning on and off a background sound file. I need it to be off by default.
This is the code I have so far and it works except for the default. It is defaulting to on as opposed to off.
<BODY>
<BGSOUND id=BGSOUND_CTRL src="water.mp3">
<script type="text/javascript">
var flip = "Stop Ambiance";
function toggle() {
if (flip == "Stop Ambiance") {
flip = "Start Ambiance";
document.all['BGSOUND_CTRL'].src=""
str ='<input name="dUit" type="button" value="Start Ambiance" ';
str+='class="midCtrl" onclick="toggle();">';
document.getElementById('midCtrl').innerHTML=str;
}
else {
flip = "Stop Ambiance";
document.all['BGSOUND_CTRL'].src="water.mp3"
str ='<input name="dUit" type="button" value="Stop Ambiance"';
str+='class="midCtrl" onclick="toggle();">';
document.getElementById('midCtrl').innerHTML=str;
}
}
</script>
<div id="midCtrl" class="midCtrl">
<input name="dUit" type="button" class="midCtrl" value="Stop Ambiance" onclick="toggle();">
</div>
Does anyone know how I need to change this so that the default is OFF?
Thanks in advance!