我在jsp页面中有两个选择输入字段。我想根据第一个输入的值禁用第二个输入。我写了这个函数。但它没有用,请帮助。
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;
}
}
输入字段为:
<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>
答案 0 :(得分:1)
第二次下拉的ID是多少?试试这句话
document.getElementById('<id of 2nd dropwon>').disabled = 'true';