我有这个 jsp 页面,如果单击单选按钮,其中一个小节应该变得不可见,并且选择列表中的选项应该改变。
<center>
<span class="ReportSubsectionTitle">Report Type</span>
<br />
<html:radio styleId="detail" property="reportOutputStyleID" onclick="doSummary();" value="1" />Pending Funding
<html:radio styleId="summary" property="reportOutputStyleID" onclick="doDetail();" value="2" />Previously Funded
</center>
<script>
function doDetail(){
document.getElementById("narrowByDateRangeTop").checked = false;
document.getElementById("narrowByDateRangeBottom").checked = false;
document.getElementById("narrowByDateRangeTop").disabled = true;
document.getElementById("narrowByDateRangeBottom").disabled = true;
document.getElementById("dateRangeTypeID").disabled = true;
document.getElementById("dateRangeLabel").disabled = true;
document.getElementById("startDateStr").disabled = true;
document.getElementById("startDateLabel").disabled = true;
document.getElementById("startDateCalendarTrigger").disabled = true;
document.getElementById("endDateStr").disabled = true;
document.getElementById("endDateLabel").disabled = true;
document.getElementById("endDateCalendarTrigger").disabled = true;
document.getElementById("startDateTime").disabled = true;
document.getElementById("endDateTime").disabled = true;
document.getElementById("narrowByDateRangeTop").style.visibility = "hidden";
document.getElementById("narrowByDateRangeBottom").style.visibility = "hidden";
document.getElementById("dateRangeTypeID").style.visibility = "hidden";
document.getElementById("dateRangeLabel").style.visibility = "hidden";
document.getElementById("startDateStr").style.visibility = "hidden";
document.getElementById("startDateLabel").style.visibility = "hidden";
document.getElementById("startDateCalendarTrigger").style.visibility = "hidden";
document.getElementById("endDateStr").style.visibility = "hidden";
document.getElementById("endDateLabel").style.visibility = "hidden";
document.getElementById("endDateCalendarTrigger").style.visibility = "hidden";
document.getElementById("startDateTime").style.visibility = "hidden";
document.getElementById("endDateTime").style.visibility = "hidden";
document.getElementById("DateSelection").style.visibility = "hidden";
}
function doSummary(){
document.getElementById("narrowByDateRangeTop").checked = true;
document.getElementById("narrowByDateRangeBottom").checked = false;
document.getElementById("narrowByDateRangeTop").disabled = false;
document.getElementById("narrowByDateRangeBottom").disabled = false;
document.getElementById("dateRangeTypeID").disabled = false;
document.getElementById("dateRangeLabel").disabled = false;
document.getElementById("startDateStr").disabled = false;
document.getElementById("startDateLabel").disabled = false;
document.getElementById("startDateCalendarTrigger").disabled = false;
document.getElementById("endDateStr").disabled = false;
document.getElementById("endDateLabel").disabled = false;
document.getElementById("endDateCalendarTrigger").disabled = false;
document.getElementById("startDateTime").disabled = false;
document.getElementById("endDateTime").disabled = false;
document.getElementById("narrowByDateRangeTop").style.visibility = "visible";
document.getElementById("narrowByDateRangeBottom").style.visibility = "visible";
document.getElementById("dateRangeTypeID").style.visibility = "visible";
document.getElementById("dateRangeLabel").style.visibility = "visible";
document.getElementById("startDateStr").style.visibility = "visible";
document.getElementById("startDateLabel").style.visibility = "visible";
document.getElementById("startDateCalendarTrigger").style.visibility = "visible";
document.getElementById("endDateStr").style.visibility = "visible";
document.getElementById("endDateLabel").style.visibility = "visible";
document.getElementById("endDateCalendarTrigger").style.visibility = "visible";
document.getElementById("startDateTime").style.visibility = "visible";
document.getElementById("endDateTime").style.visibility = "visible";
document.getElementById("DateSelection").style.visibility = "visible";
}
</script>
然后,我将这个小节标记为“日期选择”,我想让它变得不可见:
<tr>
<td align="center" style="padding-bottom: 5px;">
<span id = "DateSelection" class="ReportSubsectionTitle">Date Selection</span>
</td>
<td align="center" style="padding-bottom: 5px;">
<span class="ReportSubsectionTitle">Save Generated Report?</span>
</td>
</tr>
<tr>
<td valign="top" nowrap="nowrap">
<%@ include file="dateSelectionSection1.jsp" %>
</td>
<td valign="top" nowrap="nowrap" style="padding-left: 10px;">
<%@ include file="savedReportNameField.jsp" %>
</td>
</tr>
我有一个选择列表
<span style="padding-left: 5px;">
Date Type:
<html:select property="dateTypeID">
<html:options collection="dateTypes" property="id" labelProperty="name"/>
</html:select>
</span>
我尝试将 id 添加到选择中,但它收到一个错误,提示找不到标签。我想更改下拉菜单下的选择并锁定选择。
我尝试了 document.getElementById("dateTypeID").options[0].selected = 1。但是,之后没有任何变化。
我是 JSP 新手,不太清楚如何处理这个问题。