[b]1:js [/b]
/搜索部门
function fn_list_user(u){
$("#u_list").css("display","block");
if(u.value!=''){
jQuery.ajaxSetup ({cache:false});
$.post("announceTaskAction!listByFsName.action",{deptName:u.value},function(data){
$("#u_list").html("<ul style='margin-left:3px;'>"+data+"</ul>");
});
}
}
function fn_set_user(launchDep,deptId){
$("#launchDep").val(launchDep);
$("#deptId").val(deptId);
$("#u_list").css("display","none");
$("#u_list").html("");
}
function fn_b(){
if($("#launchDep").val()==""){
$("#u_list").css("display","none");
$("#deptId").val("");
}
}
function fn_s(str){
with(pos(str)){
$("#u_list").css("left",Left + "px");
$("#u_list").css("top",Top + 20+ "px");
if(str.value!=""){
$("#u_list").css("display","block");
}
}
}
var pos=function(str){
//获取元素绝对位置
var Left=0,Top=0;
do{Left+=str.offsetLeft,Top+=str.offsetTop;}
while(str=str.offsetParent);
return {"Left":Left,"Top":Top};
}
[b]2:html[/b]
<div id="u_list"></div>
<input type="text" class="not_null" style="width:108px;" οnfοcus="fn_s(this)" οnblur="fn_b();" οnkeyup="fn_list_user(this);" id="launchDep"/>
[b]3:css[/b]
<style type="text/css">
#u_list{position:absolute; width:122px;right:230px; text-align:left; border: 1px solid #000;BACKGROUND-COLOR: #fff;display:none; z-index:9999;overflow-y:auto;height:250px;}
</style>
[b]4:action[/b]
//模糊查找部门信息
public void listByFsName(){
PrintWriter out = null;
String deptName = request.getParameter("deptName");
if(StringUtils.isNotBlank(deptName)){
try {
out = response.getWriter();
List<Object> deptList = annTaskInfoService.queryDeptInfo(deptName);
StringBuffer buffer = new StringBuffer();
if(deptList.size()>0){
for(int i=0;i<deptList.size();i++){
Object[] deptInfo = (Object[])deptList.get(i);
String trcss = i%2==0?"li_2":"li_1";
buffer.append("<li class='"+trcss+"'><a href='javascript:void(0);' οnclick='fn_set_user(\""+deptInfo[2]+"\",\""+deptInfo[0]+"\");return false;' style='cursor:pointer'>"+deptInfo[2]+"</a></li>");
}
out.write(buffer.toString());
}else{
out.write("<li><span>没有此部门</span></li>");
}
} catch (Exception e) {
out.write("<li><span>没有此部门</span></li>");
}
}
}
/搜索部门
function fn_list_user(u){
$("#u_list").css("display","block");
if(u.value!=''){
jQuery.ajaxSetup ({cache:false});
$.post("announceTaskAction!listByFsName.action",{deptName:u.value},function(data){
$("#u_list").html("<ul style='margin-left:3px;'>"+data+"</ul>");
});
}
}
function fn_set_user(launchDep,deptId){
$("#launchDep").val(launchDep);
$("#deptId").val(deptId);
$("#u_list").css("display","none");
$("#u_list").html("");
}
function fn_b(){
if($("#launchDep").val()==""){
$("#u_list").css("display","none");
$("#deptId").val("");
}
}
function fn_s(str){
with(pos(str)){
$("#u_list").css("left",Left + "px");
$("#u_list").css("top",Top + 20+ "px");
if(str.value!=""){
$("#u_list").css("display","block");
}
}
}
var pos=function(str){
//获取元素绝对位置
var Left=0,Top=0;
do{Left+=str.offsetLeft,Top+=str.offsetTop;}
while(str=str.offsetParent);
return {"Left":Left,"Top":Top};
}
[b]2:html[/b]
<div id="u_list"></div>
<input type="text" class="not_null" style="width:108px;" οnfοcus="fn_s(this)" οnblur="fn_b();" οnkeyup="fn_list_user(this);" id="launchDep"/>
[b]3:css[/b]
<style type="text/css">
#u_list{position:absolute; width:122px;right:230px; text-align:left; border: 1px solid #000;BACKGROUND-COLOR: #fff;display:none; z-index:9999;overflow-y:auto;height:250px;}
</style>
[b]4:action[/b]
//模糊查找部门信息
public void listByFsName(){
PrintWriter out = null;
String deptName = request.getParameter("deptName");
if(StringUtils.isNotBlank(deptName)){
try {
out = response.getWriter();
List<Object> deptList = annTaskInfoService.queryDeptInfo(deptName);
StringBuffer buffer = new StringBuffer();
if(deptList.size()>0){
for(int i=0;i<deptList.size();i++){
Object[] deptInfo = (Object[])deptList.get(i);
String trcss = i%2==0?"li_2":"li_1";
buffer.append("<li class='"+trcss+"'><a href='javascript:void(0);' οnclick='fn_set_user(\""+deptInfo[2]+"\",\""+deptInfo[0]+"\");return false;' style='cursor:pointer'>"+deptInfo[2]+"</a></li>");
}
out.write(buffer.toString());
}else{
out.write("<li><span>没有此部门</span></li>");
}
} catch (Exception e) {
out.write("<li><span>没有此部门</span></li>");
}
}
}