Hi, I have one selection (R4) and want to hide input (color1other) unless selected "other"
so far the input stays on all the the time
any help how to make it work, please?
<style type="text/css">
.hidden {
display: none;
}
</style>
<script type="text/javascript">
function enableOther()
{
if (!document.getElementById) return;
var s = document.getElementById('R4');
if (!s) return;
if (s.options[s.selectedIndex].value != 'yes') return;
var t = document.getElementById('color1other');
if (!t) return;
t.disabled = false;
t.className = '';
}
function init()
{
if (!document.getElementById) return;
var s = document.getElementById('R4');
if (!s) return;
s.onchange = enableOther;
var t = document.getElementById('color1other');
if (!t) return;
t.disabled = true;
t.className = 'hidden';
}
window.onload = init;
</script>
...
<td width="*"><select size="1" id="R4" name="R4" onchange="enableOther(this);">
<option selected value="noSS">Sand Stone (Ral 1019)</option>
<option value="noEW">Euro White (Ral 9010)</option>
<option value="noQG">Quartz Grey (Ral 8014)</option>
<option value="noJB">Java Brown (Ral 8014)</option>
<option value="yes">other</option>
<input type="text" id="color1other" name="color1other" Size=15>
</td>
so far the input stays on all the the time
any help how to make it work, please?
<style type="text/css">
.hidden {
display: none;
}
</style>
<script type="text/javascript">
function enableOther()
{
if (!document.getElementById) return;
var s = document.getElementById('R4');
if (!s) return;
if (s.options[s.selectedIndex].value != 'yes') return;
var t = document.getElementById('color1other');
if (!t) return;
t.disabled = false;
t.className = '';
}
function init()
{
if (!document.getElementById) return;
var s = document.getElementById('R4');
if (!s) return;
s.onchange = enableOther;
var t = document.getElementById('color1other');
if (!t) return;
t.disabled = true;
t.className = 'hidden';
}
window.onload = init;
</script>
...
<td width="*"><select size="1" id="R4" name="R4" onchange="enableOther(this);">
<option selected value="noSS">Sand Stone (Ral 1019)</option>
<option value="noEW">Euro White (Ral 9010)</option>
<option value="noQG">Quartz Grey (Ral 8014)</option>
<option value="noJB">Java Brown (Ral 8014)</option>
<option value="yes">other</option>
<input type="text" id="color1other" name="color1other" Size=15>
</td>