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

<td align="left" width="17%">
报表名称:
<select name="formCode" style="width: 200px;" class="selectTwo" οnchange="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>

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

注意:

 

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

事件为:οnchange="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=="上半年")
   {
     document.getElementById("reportTime_half").value="上半年";
     
   }
   if(code=="下半年")
   {
     document.getElementById("reportTime_half").value="下半年";
   }
   //alert('code: '+code);
   //alert('document.getElementById("reportTime_half").value: '+document.getElementById("reportTime_half").value);
  }   
</script>
</head>
<body topmargin=0 leftmargin=0 rightmargin=0 bottomMargin=0>
<form method=post name=form4 id="form4" οnsubmit="return true;" action="cjjg/areaDataGatherSearch.action">
 <table width="99%" border="0" cellpadding="0" cellspacing="1" id="test"  bgColor=eef7ff align="center" class="tableBorderBlue" style="margin-top:5px;">
   <tr> 
    <td align="left" width="19%">
       报表名称:
       <select name="formCode" style="width: 200px;" class="selectTwo" οnchange="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>
   
    <td align="right" width="5%" >查询年份:</td>
   <td  align="left" colspan="2" width="5%" >
   <%
    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(System.currentTimeMillis());
    int year = cal.get(Calendar.YEAR);  
   %>
   <select name="reportTime" id="reportTime">
    <%if(StringUtils.isNotEmpty(reportTime)) {%>
     <option value="<%=reportTime.substring(2) %>" selected="selected">         
      <%=reportTime.substring(2) %>
     </option>
    <%} %>
    <%
     for(int i=0;i<30;i++){
      if((String.valueOf(year-i+1)).equals(reportTime)){
    %>
    <option value="<%=year-i+1 %>" selected="selected"><%=year-i+1 %></option>
    <%   
      }else{
    %>
    <option value="<%=year-i+1 %>"><%=year-i+1 %></option>
    <%}}%>
   </select>
   </td>
   
   
   
   <td  align="right" colspan="2" width="5%"  >   
       <table width="100%" border="0" id="tj" align="center" cellpadding="0" cellspacing="0" style="display:none;">
      <tr id="yin2" >
        <td width="2%" align="right" >
              期别:
        </td>
           <td align="left" width="3%">
          
                   <select name="reportTime_half" id="reportTime_half" type="hidden" >

            <option   value= "上半年" selected="selected">上半年 </option>
            <option   value= "下半年" >下半年  </option>
          </select>
          
          <!-- 
          <input class="inputOne" name="quYuShengName" id="quYuShengName" style="width: 490px" type="text" value="${quYuSheng[0] }">
          <input type="hidden" name="quYuShengId" id="quYuShengId"  value="${shengs[1] }">        
          <input type="hidden" name="ff" id="ff"> -->        
          <!-- 使用的源代码
          <input type="button" class="button_select" value="选择"  οnclick="choose_tj();">  
          -->   
           </td>
      </tr>
                </table>   
   </td>

    <%if(StringUtils.isNotEmpty(reportTime_half) && reportTime_half!=null ) {%>
      <td  align="right" colspan="1" width="3%"  type="hidden" id="reportTime_half2">期别:
      </td>
      <td  align="left" colspan="1" width="3%" >
      <select name="reportTime_half" id="reportTime_half1" type="hidden" οnchange="select_q(this.options[this.selectedIndex].value);">

                <%if(StringUtils.isNotEmpty(reportTime_half)) {%>
          <option value="<%=reportTime_half %>" selected="selected">         
           <%=reportTime_half %>
          </option>
          <option   value= "上半年" >上半年 </option>
          <option   value= "下半年" >下半年  </option>  
                         <%} %>              
            
      </select>
      </td>
    <%} %>

   <td  align="right" width="5%">&nbsp;地&nbsp;&nbsp;区:</td>
   <td align="left" width="15%">
   <input class="inputOne" name="reportAreaName" ID="reportAreaName" readonly  type="text" value="${reportAreaName }">&nbsp;
   <input class="inputOne" name="reportAreaid" ID="reportAreaid" readonly  type="hidden" value="${reportAreaid }">&nbsp;
   <input type="button" class="button_select" value="选择" οnclick="selectOrg();"></td>
   <td align="right" width="10%">
      <input type="button" class="button_search" value="查&nbsp;询" οnclick="javascript:mySubmit('form4',this,'<c:url value='/cjjg/areaDataGatherSearch.action'/>')"></td> 
        </tr>
   </table>
 </form>
   <table>
 <% if(StringUtils.isNotEmpty(formCode)) {%> 
  <tr><td>
   <report:html name="report1" reportFileName="<%=raq%>"
            funcBarLocation=""
            params="<%=params%>"
            height="1200"
            width="800"
            needScroll="yes"
            scrollHeight="400"
            scrollWidth="1200"
           />
  </td></tr>
  <tr><td>
   <input type="button"  value="存为Excel" class="button_excel" οnclick="report1_saveAsExcel();">
   <input type="button" class="button_print" name="add" value="打印" onClick="report1_print();">
  </td></tr>
 <%} %> 
   </table>
         
</body>
</html>

>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值