JavaScript works in Chrome, IE and Safari but not in Firefox
First time posting on here, so I hope I do this correctly, however I have searched here and Google for a solution to my problem and have not found it.
The JavaScript is changing the style.display of an HTML div using onkeyup. I'm not sure if this is something that isn't supposed to work, but I cannot seem to figure out why it works perfectly in IE and Chrome, but not in Firefox.
Here is the JS:
function q8a()
{
var q8a = document.getElementById('q8a_days');
var q8a_n = document.getElementById('q8a_n');
var q8arrow = document.getElementById('q8arrow');
if(!q8a_n.checked)
{
if(q8a.value >= 1 && q8a.value <= 7) {
q8b.style.display = '';
q8arrow.style.display = '';
}
else
{
q8b.style.display = 'none';
q8arrow.style.display = 'none';
}
}
}
and the HTML it is changing:
<tr >
<td colspan="4">
<div id="q8a" >
<p>8a. **Question** </p>
<input id="q8a_days" name="q8a_days" type="text" maxlength="1" size="2" onkeyup="q8a()" /> days <br />
</div>
</td>
</tr>
<tr >
<td>
</td>
<td>
<p>
<b>OR</b><br />
</p>
<input id="q8a_n" name="q8a_n" type="checkbox" value="sadface" onclick="noshow8b()" />None
</td>
<td class="arrow" >
<div id="q8arrow" style="display:none">
------>
</div>
</td>
<td class="b" colspan="2">
<div id="q8b" style="display:none"开发者_开发百科>
<p>8b. **Question** </p>
<p id="q8bwords">
<input id="q8b_hours" name="q8b_hours" type="text" maxlength="1" size="1" /> hours <br />
<input id="q8b_minutes" name="q8b_minutes" type="text" maxlength="2" size="1" /> minutes
</p>
</div>
</td>
</tr>
So could anyone help me make this script work in Firefox?
Any help would be greatly appreciated.Thanks!
It seems q8b
is undefined, so add the following code in function q8a()
:
var q8b = document.getElementById('q8b');
精彩评论