<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="ww" uri="/struts-tags" %>
<%@ page import="com.ego.baseInfo.technicl.model.*" %>
<%@ page import="java.util.List" %>
<%@ page import=com.ego.baseInfo.technicl.* %>
<%@ page import="org.springframework.context.ApplicationContext" %>
<%@ page import="org.springframework.context.support.ClassPathXmlApplicationContext" %>
<%
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>
<title></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"> <link rel="STYLESHEET" type="text/css" href="dhtmlx2.6/dhtmlxtree.css">
<link rel="stylesheet" type="text/css" href="dhtmlx2.6/dhtmlxlayout.css">
<link rel="stylesheet" type="text/css" href="dhtmlx2.6/skins/dhtmlxtoolbar_dhx_skyblue.css">
<link rel="stylesheet" type="text/css" href="dhtmlx2.6/skins/dhtmlxlayout_dhx_skyblue.css">
<link rel="stylesheet" type="text/css" href="dhtmlx2.6/dhtmlxgrid.css">
<link rel="stylesheet" type="text/css" href="dhtmlx2.6/skins/dhtmlxgrid_dhx_skyblue.css">
<style>
label{ display:block; }
input {margin-bottom:3px; width:85%;}
textArea {margin-bottom:5px;  width:85%;height: 60 }
#form_container{width: 200; height: 100%; overflow: auto;  font-family: Tahoma; font-size: 12px;}
#form_left{padding:5px;width:93%;text-align: center;margin-left:5px;}
.validateTips {border: 0px solid transparent; margin:20px 5px 5px 5px; }
.even{
    background-color:#E6E6FA;
}
.uneven{
    background-color:#F0F8FF;
}
</style>
<script>
window.dhx_globalImgPath="dhtmlx2.6/imgs/";
</script>
<script src="dhtmlx2.6/dhtmlxcommon.js"></script>
<script src="dhtmlx2.6/dhtmlxwindows.js"></script>
<script src="dhtmlx2.6/dhtmlxtree.js"></script>
<script src="dhtmlx2.6/dhtmlxlayout.js"></script>
<script src="dhtmlx2.6/dhtmlxtoolbar.js"></script>
<script src="dhtmlx2.6/dhtmlxgrid.js"></script>
<script src="dhtmlx2.6/dhtmlxgridcell.js"></script>
<script src="dhtmlx2.6/ext/dhtmlxgrid_srnd.js"></script>
<script src="dhtmlx2.6/dhtmlxcontainer.js"></script>
<script src='dhtmlx2.6/dhtmlxgrid_export.js'></script>
<script src='js/simple-validate.js'></script>
<script src='js/common-grid-form.js'></script>
<script src='js/simple-grid-form.js'></script>
<script type="text/javascript">

</script>

</head>
<body onload="doOnLoad()">
 

<div id="form_container">
<form id="myform" method="post" >
<div id="form_tips" class="validateTips"></div>
<fieldset id="form_left">
<!-- 案件类型表ID -->

<label>上级科室名称编号:
<input type="text" name="technicl.techniclToId" id="techniclToId"/>

<select name="select" id="select">
                    
                       <option value=""> fdfafdsf</option>
                    
                          </select>
</label>
<label>上级科室名称:
<input type="text" name="technicl.techniclToName" id="techniclToName"/>
</label>
<label>科室编号:
<input type="text" name="technicl.id" id="id" onblur="checkTechniclExists()"/>
</label>
<label>科室名称:
<input type="text" name="technicl.techniclName" id="techniclName"/>
</label>

   <!--   <input type="submit" name="button" id="button" value="新添加上级科室"  onClick="adda()"/> 
<input type="submit" name="button1" id="button1" value="e"/>-->
    
<label>备注:
<input type="text" name="technicl.re" id="re"/>
</label>
</fieldset>
</form>
</div>
<script>
var dhxLayout,winCheck;
//初始化验证控件,会默认初始化提示信息
var sValid=new SimpleValidate({
isNotExists:true,
origMsg:"提示:科室编号,科室名称,上级科室名称为必填",
tipsId:"form_tips"});
function doOnLoad() {
//布局

    dhxLayout = new dhtmlXLayoutObject(document.body, "2U");
    dhxLayout.cells("a").hideHeader();
     dhxLayout.cells("a").setWidth(480);
    
     sgf =new SimpleGridForm({
         gridContainer:dhxLayout.cells("a"),
         formContainer:dhxLayout.cells("b"),
         gridConf:{
     header:"科室编号,科室名称,,上级科室名称,备注",
     initWidthsP:"25,25,0,25,25",
     colAlign:"center,center,center,center,center"    
     },
     gridLoadAction:"allTechnicl.action",
     sValid:sValid,
     objectId:"form_container",
     formId:"myform",
     addAction:"saveTechnicl.action",
     toUpdateAction:"toUpdateTechnicl.action?technicl.id=",
     updateAction:"updateTechnicl.action",
     deleteAction:"delTechnicl.action",
repStr:"technicl."
     })
     sgf.init();
     sgf.doSave=function(){
var _id,_brlx,
bValid = true;
_id=document.getElementById("id");
_brlx=document.getElementById("techniclName");
var _brxz=document.getElementById("techniclToName");
var _brxa=document.getElementById("techniclToId");
bValid = sValid.isNotExists
bValid = bValid&&sValid.checkNull(_id, "编号不能为空!");
bValid = bValid&&sValid.checkNull(_brlx, "科室名称不能为空!");
bValid = bValid&&sValid.checkNull(_brxa, "上级科室编号不能为空!");
bValid = bValid&&sValid.checkNull(_brxz,"上级科室名称不能为空");
bValid = bValid&&sValid.checkLength(_id,"编号最长为38位",1,38);
if(bValid)
sgf.doSubmit();
     }
    
}
//判断对象主键是不是存在
function checkTechniclExists(){
var rowId=sgf.grid.getSelectedId();
var _id=document.getElementById("id");
sValid.checkExistsAction="isTechniclExists.action",
sValid.checkExists(_id,"序号",sgf.addOrUpdate=="add"?"":rowId,"technicl.id=");
}
</script>
</body>
</html>
  这是用dhtml 做的  现在我想把表单myform里上级科室编号和 上级科室名称从数据库是遍历出到下拉列表中怎么做呀

解决方案 »

  1.   

    用ajax,在myForm 的load完成后做
      

  2.   

    <%
    String sqlStatement;
    int length = 0;DB dbquery = new DB("数据库名");//DB获得连接数据库的类
    try{
        sqlStatement = "sql语句,查询出你要显示的上级科室编号";
        dbquery.query(sqlStatement);
    }catch(Exception e){
        out.println("Database Error!");
    }
    dbquery.getLength();
    %>select中:
    <%
    for(int i = 0; i<length; i++){
    %>
        <option>
            <%=dbquery.get(i)%>
        </option>
    <%
    }
    try{
        dnquery.over();
    }catch(Throwable e){
         e.printStackTrance();
    }
    %>