日期:2014-05-16  浏览次数:20378 次

jsp下拉框事件,点击某项隐藏和显示某单元格 事件(测试通过)

<td align="left" width="17%">
报表名称:
<select name="formCode" style="width: 200px;" class="selectTwo" onchange="selectCode(this.options[this.selectedIndex].value);" >

<%if(StringUtils.isEmpty(formCode)) {%>
<option value="">
---
<fmt:message key="common.choose" />
---
</option>
<%} %>
<c:forEach items="${forminfoList}" var="forminfoVO">
<c:if test="${forminfoVO.formCode==formCode}">
<option value="${forminfoVO.formCode}" selected>
${forminfoVO.formName}
</option>
</c:if>
<c:if test="${forminfoVO.formCode!=formCode}">
<option value="${forminfoVO.formCode}">
${forminfoVO.formName}
</option>
</c:if>
</c:forEach>
</select>
</td>

--------------------------------------------------

注意:

?

当选中半年报时, 显示半年报期别的选择下拉框;当年报时隐藏下拉框。开始默认为隐藏半年报的下拉框部分。

事件为:onchange="selectCode(this.options[this.selectedIndex].value);"

?

--------------------------------------------------

?

源码记录:

?

<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/WEB-INF/taglib/pager/pagetag.tld" prefix="page" %>
<%@ taglib uri="/WEB-INF/taglib/jstl/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/taglib/jstl/fmt.tld" prefix="fmt"%>
<%@ taglib uri="/WEB-INF/taglib/runqian/runqianReport4.tld" prefix="report"%>
<%@ include file="/common/head.jsp" %>
<%@ page import="java.util.*"%>
<%@ page import="org.apache.commons.lang.StringUtils"%>

<%
???String path = request.getContextPath();
???String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
???String formCode = (String)request.getAttribute("formCode");
???String raq = "/cjjg/areaDataGatherSearch/"+formCode+".raq";
???
???String reportTime = "";
???if(request.getAttribute("reportTime")!=null){
????reportTime = "N-"+(String)request.getAttribute("reportTime");????????? //年份的返回值
???}

???String belongunit = (String)request.getAttribute("belongunit");
???String reigonCode = (String)request.getAttribute("reportAreaCode");
???String reportTime_half = (String)request.getAttribute("reportTime_half");? //半年报期别的返回值
???System.out.println("reportTime_half:"+reportTime_half);
???//^3-1-1-[0-9]{1,}$
???String likeReigonCode = "^"+reigonCode + "-[0-9]{1,}$";
???
???String params = "formCode="+formCode+";period="+reportTime+";reigonCode="+reigonCode+";likeReigonCode="+likeReigonCode+";belongunit="+belongunit;
%>
<html>
<head>
<script type="text/javascript">
??function mySubmit(myform,obj,url){
???document.getElementById("form4").submit();
???//window.location.href=url;
??}
???
??function selectOrg(){
???var selectedcodes="${loginOrgCode }";
???showModalDialog("<c:url value='/pages/orgTree/orgTree.jsp'/>",
????{
????selectednodes:selectedcodes,??
????returnleaf:false,
????singleselect:true,
????action:function(rtparams){
?????document.getElementById("reportAreaid").value=rtparams.selectleafids;
?????document.getElementById("reportAreaName").value=rtparams.selectleafnames;
????}
????},
???'dialogWidth:300px;dialogHeight:500px;status:no;scroll:auto');??
??}

??function selectCode(code)
??{ ???
???if(code=="R01038")
???{
?????? document.getElementById("tj").style.display="block";
???}
???if(code!="R01038")
???{
??????? document.getElementById("tj").style.display="none";
??????? document.getElementById("reportTime_half1").style.display="none";
??????? document.getElementById("reportTime_half2").style.display="none";
???}
??}
??select_q
??function select_q(code)
??{ ???
???if(code=="上半年")
???{
?????doc