K
Kingo
Hi,
First, please forgive my terrible knowledge of JS! I haven't used it in
years.
I am trying to create a Help page where a new question is on each line,
and when clicking on the question, the answer is written below it.
Click on the question again removes the answer. (Basically the Q/A is
being toggled).
I am using the following JS code for each Question (probably not the
best way):
<script language="JavaScript">
function Help1Toggle() {
if(document.help.help1display.value='N') {
document.getElementById('Help1').innerHTML = '<b>A</b> This is the
answer.';
document.help.help1display.value='Y';
}
else if(document.help.help1display.value='Y') {
document.getElementById('Help1').innerHTML = '';
document.help.help1display.value='N';
}
}
</script>
The HTML on the page is:
<form name="help">
<input type="hidden" name="help1display" value="N">
<a href="javascript:;" onClick="Help1Toggle();"><b>Q</b> This is the
Question?</a><br>
<span id="Help1"></span>
</form>
Now, when the page loads, the Question(s) are displayed (and answers
hidden). Clicking on a Question writes the answer below it properly,
and changes the value of the textbox to Y. Problem is, clicking on the
Question again doesn't do anything. It doesn't change the textbox value
to N, and doesn't hide the question. No JS errors are reported. I've
tried this in both Firefox and IE.
Any ideas/easier ways of doing this?
Cheers,
Kingo
First, please forgive my terrible knowledge of JS! I haven't used it in
years.
I am trying to create a Help page where a new question is on each line,
and when clicking on the question, the answer is written below it.
Click on the question again removes the answer. (Basically the Q/A is
being toggled).
I am using the following JS code for each Question (probably not the
best way):
<script language="JavaScript">
function Help1Toggle() {
if(document.help.help1display.value='N') {
document.getElementById('Help1').innerHTML = '<b>A</b> This is the
answer.';
document.help.help1display.value='Y';
}
else if(document.help.help1display.value='Y') {
document.getElementById('Help1').innerHTML = '';
document.help.help1display.value='N';
}
}
</script>
The HTML on the page is:
<form name="help">
<input type="hidden" name="help1display" value="N">
<a href="javascript:;" onClick="Help1Toggle();"><b>Q</b> This is the
Question?</a><br>
<span id="Help1"></span>
</form>
Now, when the page loads, the Question(s) are displayed (and answers
hidden). Clicking on a Question writes the answer below it properly,
and changes the value of the textbox to Y. Problem is, clicking on the
Question again doesn't do anything. It doesn't change the textbox value
to N, and doesn't hide the question. No JS errors are reported. I've
tried this in both Firefox and IE.
Any ideas/easier ways of doing this?
Cheers,
Kingo