How to hide/show a text box when a select box only has 1 option
<p>My problem is that I am making a web page with javascript, where the user can choose an option from the select box#1 and depending on his option, then I will show a textbox or a selectbox#2.</p>

<p>When the user has selected an option in select box #1 the select box#2 should show the options that correspond to select box #1. One thing in common is that the "new" option is supposed to be show on every select box#2</p>

<p>My problem is that if a certain option in select box#2 only has the option "new", then I should show a textbox  and hide the select box#2</p>

<p>I used this code for javascript:</p>

<pre><code>if (str =='Select'){
    comm.style.display='none';
    comm.disabled=true;
    comm.value='';
    comm.style.visibility='hidden';

    textNumber.style.visibility='visible';
    textNumber.disabled=false;
    textNumber.focus();

    textic.style.visibility='hidden';
    textic.disabled=true;
    textic.value='';

    document.getElementById('btnComm').value='Add';}
else{
if (comm.length == 1){
    comm.style.display='none';
    comm.disabled=true;
    comm.value='';
    comm.style.visibility='hidden';

    textNumber.style.visibility='visible';
    textNumber.disabled=false;
    textNumber.focus();

    textic.style.visibility='hidden';
    textic.disabled=true;
    textic.value='';

    document.getElementById('btnComm').value='Add';}
else {
    comm.style.display='';
    comm.disabled=false;
    comm.style.visibility='visible';

    textNumber.style.visibility='hidden';
    textNumber.disabled=true;
    textNumber.value='';

    textic.style.visibility='hidden';
    textic.disabled=true;
    textic.value='';

    document.getElementById('btnComm').value='Update';}
</code></pre>

<p>In my html page page I have the onchange event to hide/show the select box#2 when necessary</p>

<p>But it does not work correctly, it hides the select box#2, but only after I change to another option in select box#1 (which is supposed to happen before that).</p>

<p>Thanks</p>
