I've have two divisions and I have a question and if the answer is yes I want to hide the first division and show the second. If the answer is anything else I want to hide them both.
Since they answer can only be yes or no, I'm using an onkeydown function to sort out the display options.
When I run it, all that happens is the both divisions are hidden whatever I type. If I hide the code in the else then press 'y' nothing happens but if I then delete it, it show the correct division. Am I missing something here?
Code:
<div id="title" style="display: block; width: 900px; height: 475px; margin: 0 auto;"> [I]some content[/I] </div> <div id="instructions" style="display: none; width: 900px; height: 475px; margin: 0 auto;"> [I]other content[/I] </div>
Code:
<input type="text" name="instruction" id="instruction" onkeydown="toggle_visibility()" style="width: 20px; border: 0; font-size: 14pt;"/>
Code:
<script type="text/javascript">
<!--
function toggle_visibility() {
var a = document.getElementById('title');
var b = document.getElementById('instructions');
if (document.story.instruction.value == "y")
{
a.style.display = 'none';
b.style.display = 'block';
}
else
{
a.style.display = 'none';
b.style.display = 'none';
}
}
//-->
</script>
Comment