0

i have two select input fields in a jsp page. i want to disable the second input based on the value of first input. i wrote the function. but it is not working, plz help.

function selectTimePeriod()
{

var rtype = document.getElementById('customer.customerType').value;
var corporateSize = document.getElementById("customer.corporateSize").value;

if(rtype == "PRS" )
  {
   document.getElementById("corporateClient").style.display = 'none';    
   document.getElementById("prjClient").style.display = 'none';    

   document.getElementById("prsClient").style.display = '';
   corporateSize.disabled=true;
  }

}

the input fields are:

            <td>
            <html:select property="customer.customerType" styleId="customer.customerType" onchange="selectTimePeriod()">
                <%
                    for (index6 = 0; index6 < Constants.customerTypeConstants.length; index6++)
                    {
                %>
                        <html:option value="<%=Constants.customerTypeConstants[index6][0]%>"><%=Constants.customerTypeConstants[index6][1]%></html:option>
                <%        
                    }
                %>
            </html:select>
        </td>

    </tr>

    <tr >
    <td><label class="desc"><bean:message key="label.customer.corporateSize"/></label></td>
        <td>
            <html:select property="customer.corporateSize" styleId="customer.corporateSize">
                <%
                    for (index6 = 0; index6 < Constants.corporateSizeConstants.length; index6++)
                    {
                %>
                        <html:option value="<%=Constants.corporateSizeConstants[index6][0]%>"><%=Constants.corporateSizeConstants[index6][1]%></html:option>
                <%        
                    }
                %>
            </html:select>
        </td>

1 Answer 1

1

what is the id for your 2nd drop down? try this statement

document.getElementById('<id of 2nd dropwon>').disabled = 'true';    
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.