jquery为下拉框赋值

<%@ page language="java"  pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>CNKI检索页面</title>
 <meta http-equiv="pragma" content="no-cache">
 <meta http-equiv="cache-control" content="no-cache">
 <meta http-equiv="expires" content="0">   
 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
 <meta http-equiv="description" content="This is my page">

<!--去除连接<a href>下面的横线-->

 <style type="text/css">
  <!--
  a:link {
   text-decoration: none;
  }
  
  a:visited {
   text-decoration: none;
  }
  
  a:hover {
   text-decoration: none;
  }
  
  a:active {
   text-decoration: none;
  }
  -->
  .menu{
  color: black;
  }
 </style>


<script type="text/javascript" src="<%=path %>/js/jquery.js"></script>
  </head>
 
  <body>
   <form action="#" method="post">
    <input type="hidden" name="dataBaseCode" id="dataBaseCode"/>
    <table align="center" style="margin-top: 50px;">
     <tr>
      <td>
       <img src="<%=basePath%>/images/logo.gif">
      </td>
      <td>&nbsp;&nbsp;</td>
      <td>
       <a href="#this" class="menu" οnclick="getSearchTypeList('1')">文献</a>
       <a href="#this" class="menu" οnclick="getSearchTypeList('2')">期刊</a>
       <a href="#this" class="menu" οnclick="getSearchTypeList('3')">博硕文</a>
       <a href="#this" class="menu" οnclick="getSearchTypeList('4')">会议</a>
       <a href="#this" class="menu" οnclick="getSearchTypeList('5')">报纸</a>
       <a href="#this" class="menu" οnclick="getSearchTypeList('6')">年鉴</a>
       <a href="#this" class="menu" οnclick="getSearchTypeList('7')">百科</a>
       <a href="#this" class="menu" οnclick="getSearchTypeList('8')">词典</a>
       <a href="#this" class="menu" οnclick="getSearchTypeList('9')">统计年鉴</a>
       <a href="#this" class="menu" οnclick="getSearchTypeList('10')">外文期刊</a>
      </td>
     </tr>
     <tr>
      <td>
       <select id="searchType" name="searchType" style="width: 180px;">
        <option value="全文">全文</option>
        <option value="主题">主题</option>
        <option value="篇名">篇名</option>
        <option value="作者">作者</option>
        <option value="单位">单位</option>
        <option value="关键词">关键词</option>
        <option value="摘要">摘要</option>
        <option value="参考文献">参考文献</option>
        <option value="中图分类号">中图分类号</option>
       </select>
      </td>
      <td colspan="2">
       <input type="text" name="keyWords" size="80"/>
       <input type="button" value="查询" />
      </td>
     </tr>
    </table>
   </form>
   
    <script type="text/javascript">
     function changeStyle(){
      $(".menu").css("background-color","white");
      $(document).ready(function(){
         $("a").click(function(){
          $(this).css("background-color","blue");
         });
        });
     }
     function getSearchTypeList(code){
      changeStyle();
      $("#dataBaseCode").val(code);
      var dataArr = null;
      dataArr = [{name:"全文",value:"全文"},{name:"主题",value:"主题"},{name:"作者",value:"作者"},{name:"单位",value:"单位"},
               {name:"关键词",value:"关键词"},{name:"摘要",value:"摘要"},{name:"参考文献",value:"中图分类号"}];
      var searchType = $("#searchType");
      searchType.css("display","block");
      searchType.empty();
      if(dataArr!=null){
       for(var i=0;i<dataArr.length;i++){
        var option = $("<option>").text(dataArr[i].name).val(dataArr[i].value);
        searchType.append(option);
       }
      }
     }
    </script>
  </body>
</html>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值