求高手帮忙,改进优化asp+ajax 自动完成功能,提高效率,节约生命,感激不尽,有源代码。
时间:2010-10-13
来源:互联网
我目前正在做一个销售管理系统,为了能够方便准确快速录入,绞尽脑汁。
其中有一个asp 页面 用来录入 销售单的,现在已经有ajax自动完成功能,但是这个功能使用起来非常不方便,我想改进一下,不知道怎么改,请高手帮帮忙。感激不尽~~!!!
详细说明如下:
第一个,在录入 “产品名称”的时候,出现自动完成的列表能够响应键盘鼠标。并且用键盘进行选择,回车确认的时候不要提交表单,因为我还有价格和数量没有填。目前这个系统不能用键盘进行选择,可以选,但是键盘一回车就提交表单,我的表单没有填完就提交,没有意义,虽然用鼠标可以选择,但是这样效率很低下,同样意义不大。需要改进,能用键盘选择而不提交表单。并且光标不丢失,按Tab 键 可以进行下一个文本框的录入。
第二,产品名称,规格,单位,最好能够三级联动。比如输入产品名称“一级红绳”那么到规格的时候只列出“一级红绳”的规格,单位也是一样。
最好能够在输入 产品名称的时候 能够一次性列出 产品名称、规格、单位,然后只需要一次选择 就可以对“产品名称、规格、单位”三个文本框进行填充。这样输入效率便可以大大的提高。
第三,或者哪位高手能有其他更方便快速准确地录入方法,请指教。谢谢~!!!
如需 整体代码测试运行 可到以下地址下载:
http://u.115.com/file/f79b962c20
具体代码如下:
Index.asp 页面
<!--#include file="Conn.asp"-->
<html>
<head>
<title>管理中心</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="style.css" type=text/css rel=stylesheet>
<script language="javascript" src="ajax.js" type="text/javascript"></script>
<script language="javascript" src="suggest.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
var Suggest = new Suggest();
</script>
</head>
<%
company=request("company")
sdate=request("sdate")
if sdate="" then
sdate=date()
end if
tel=request("tel")
chuhuodan=request("chuhuodan")
%>
<table width="98%" border="0" align=center cellpadding="6" cellspacing="1" class="tableBorder" id="form1">
<form onSubmit="return checkxiaoshou()" action="savexiaoshou.asp" method="get" id="form1" name="form1" autocomplete="off" >
<tr bgcolor=ffffff>
<th height=25 colspan="6" align="center">销售录入</th>
</tr>
<tr bgcolor=ffffff>
<td colspan="6" class=forumrow><label></label></td>
</tr>
<tr bgcolor=ffffff>
<td colspan="6" class=forumrow>出货日期
<input name="sdate" type="text" id="sdate" size="15" value=<%=sdate%> >
销售单号
<input name="chuhuodan" type="text" id="chuhuodan" size="15" value=<%=chuhuodan%> >
客户名称
<input name="company" type="text" id="company" size="20" value="<%=company%>" autocomplete="off" onFocus="Suggest.Search(this,'suggest_customers.asp');" >
联系电话
<input name="tel" type="text" id="tel" size="20" value=<%=tel%>>
</label></td>
</tr>
<tr bgcolor=ffffff>
<td width="25%" align="center" class=forumrow>产品名称 </td>
<td width="15%" align="center" class=forumrow>规格</td>
<td width="15%" align="center" class=forumrow>单位</td>
<td width="20%" align="center" class=forumrow>数量</td>
<td width="20%" align="center" class=forumrow>单价</td>
<td width="20%" align="center" class=forumrow>备注</td>
</tr>
<tr bgcolor=ffffff>
<td align="center" class=forumrow><label>
<input name="chanpinname" onmouseover= "this.select()" type="text" id="chanpinname" size="20" autocomplete="off" onFocus="Suggest.Search(this,'suggest.asp');" >
</label></td>
<td align="center" class=forumrow><input name="guige" type="text" id="guige" size="15" autocomplete="off" onFocus="Suggest.Search(this,'suggest_guige.asp');"></td>
<td align="center" class=forumrow><label>
<input name="danwei" type="text" id="danwei">
</label></td>
<td align="center" class=forumrow><label>
<input name="shuliang" type="text" id="shuliang" onKeypress="JHshNumberText()">
</label></td>
<td align="center" class=forumrow><label>
<input name="danjia" type="text" id="danjia" onKeypress="JHshNumberText()">
</label></td>
<td align="center" class=forumrow><label>
<input name="beizhu" type="text" id="beizhu">
</label></td>
</tr>
<tr bgcolor=ffffff>
<td colspan="6" class=forumrow> </td>
</tr>
<tr bgcolor=ffffff>
<td colspan="6" align="center" class=forumrow><label>
<input type="submit" name="Submit" value="提交" >
</label></td>
</tr>
</form>
</table>
<script> document.all.chanpinname.focus(); </script>
<p> </p>
</html>
其中有一个asp 页面 用来录入 销售单的,现在已经有ajax自动完成功能,但是这个功能使用起来非常不方便,我想改进一下,不知道怎么改,请高手帮帮忙。感激不尽~~!!!
详细说明如下:
第一个,在录入 “产品名称”的时候,出现自动完成的列表能够响应键盘鼠标。并且用键盘进行选择,回车确认的时候不要提交表单,因为我还有价格和数量没有填。目前这个系统不能用键盘进行选择,可以选,但是键盘一回车就提交表单,我的表单没有填完就提交,没有意义,虽然用鼠标可以选择,但是这样效率很低下,同样意义不大。需要改进,能用键盘选择而不提交表单。并且光标不丢失,按Tab 键 可以进行下一个文本框的录入。
第二,产品名称,规格,单位,最好能够三级联动。比如输入产品名称“一级红绳”那么到规格的时候只列出“一级红绳”的规格,单位也是一样。
最好能够在输入 产品名称的时候 能够一次性列出 产品名称、规格、单位,然后只需要一次选择 就可以对“产品名称、规格、单位”三个文本框进行填充。这样输入效率便可以大大的提高。
第三,或者哪位高手能有其他更方便快速准确地录入方法,请指教。谢谢~!!!
如需 整体代码测试运行 可到以下地址下载:
http://u.115.com/file/f79b962c20
具体代码如下:
Index.asp 页面
<!--#include file="Conn.asp"-->
<html>
<head>
<title>管理中心</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="style.css" type=text/css rel=stylesheet>
<script language="javascript" src="ajax.js" type="text/javascript"></script>
<script language="javascript" src="suggest.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
var Suggest = new Suggest();
</script>
</head>
<%
company=request("company")
sdate=request("sdate")
if sdate="" then
sdate=date()
end if
tel=request("tel")
chuhuodan=request("chuhuodan")
%>
<table width="98%" border="0" align=center cellpadding="6" cellspacing="1" class="tableBorder" id="form1">
<form onSubmit="return checkxiaoshou()" action="savexiaoshou.asp" method="get" id="form1" name="form1" autocomplete="off" >
<tr bgcolor=ffffff>
<th height=25 colspan="6" align="center">销售录入</th>
</tr>
<tr bgcolor=ffffff>
<td colspan="6" class=forumrow><label></label></td>
</tr>
<tr bgcolor=ffffff>
<td colspan="6" class=forumrow>出货日期
<input name="sdate" type="text" id="sdate" size="15" value=<%=sdate%> >
销售单号
<input name="chuhuodan" type="text" id="chuhuodan" size="15" value=<%=chuhuodan%> >
客户名称
<input name="company" type="text" id="company" size="20" value="<%=company%>" autocomplete="off" onFocus="Suggest.Search(this,'suggest_customers.asp');" >
联系电话
<input name="tel" type="text" id="tel" size="20" value=<%=tel%>>
</label></td>
</tr>
<tr bgcolor=ffffff>
<td width="25%" align="center" class=forumrow>产品名称 </td>
<td width="15%" align="center" class=forumrow>规格</td>
<td width="15%" align="center" class=forumrow>单位</td>
<td width="20%" align="center" class=forumrow>数量</td>
<td width="20%" align="center" class=forumrow>单价</td>
<td width="20%" align="center" class=forumrow>备注</td>
</tr>
<tr bgcolor=ffffff>
<td align="center" class=forumrow><label>
<input name="chanpinname" onmouseover= "this.select()" type="text" id="chanpinname" size="20" autocomplete="off" onFocus="Suggest.Search(this,'suggest.asp');" >
</label></td>
<td align="center" class=forumrow><input name="guige" type="text" id="guige" size="15" autocomplete="off" onFocus="Suggest.Search(this,'suggest_guige.asp');"></td>
<td align="center" class=forumrow><label>
<input name="danwei" type="text" id="danwei">
</label></td>
<td align="center" class=forumrow><label>
<input name="shuliang" type="text" id="shuliang" onKeypress="JHshNumberText()">
</label></td>
<td align="center" class=forumrow><label>
<input name="danjia" type="text" id="danjia" onKeypress="JHshNumberText()">
</label></td>
<td align="center" class=forumrow><label>
<input name="beizhu" type="text" id="beizhu">
</label></td>
</tr>
<tr bgcolor=ffffff>
<td colspan="6" class=forumrow> </td>
</tr>
<tr bgcolor=ffffff>
<td colspan="6" align="center" class=forumrow><label>
<input type="submit" name="Submit" value="提交" >
</label></td>
</tr>
</form>
</table>
<script> document.all.chanpinname.focus(); </script>
<p> </p>
</html>
作者: yacity 发布时间: 2010-10-13
suggest.asp 页面
<!--#include file="conn.asp"-->
<%
set rs=server.createobject("adodb.recordset")
Response.ContentType="text/xml"
k=trim(request("keyword"))
a=cint(request("a"))
sql="select chanpinname from cangku where chanpinname like '%"&k&"%' "
rs.open sql,conn,1,3
str="<?xml version=""1.0"" encoding=""gb2312""?>"
str=str&"<data>"
If rs.EOF or rs.BOF Then
str=str&"<result>false</result>"
Else
str=str&"<result>true</result>"
Do While Not rs.EOF
str=str&"<name>"
str=str&"<![CDATA["&rs("chanpinname")&"]]>"
str=str&"</name>"
rs.MoveNext
Loop
End If
str=str&"</data>"
rs.close
response.write str
%>
suggest.js 页面
function Suggest(){
this.objParent = null;
this.delaySec = 100;
this.cursor = -1;
this.objAjax = null;
this.layerWidth = 200;
this.result = 0;
this.taskID = null;
this.keyword = null;
this.url = null;
this.startIndex = 0;
}
Suggest.prototype.Search = function(objParent, url){
var This = this;
this.CreateElement(objParent);
this.keyword = this.objParent.value.replace(/(^\s*)|(\s*$)/g, "");
if(url){this.url = url;}
if(this.keyword != ""){
if(this.taskID){clearTimeout(this.taskID);this.taskID = null;}
if(!this.objAjax){this.objAjax = new Ajax();}else if(this.objAjax.readyState != 0){this.objAjax.abort();}
this.objAjax.clearParams();
this.objAjax.addParams("keyword", this.keyword);
this.objAjax.OnComplete = function(txt, xml){This.SearchResult(txt, xml);};
this.taskID = setTimeout(function(){This.objAjax.CallBack("GET",This.url);}, this.delaySec);
}
}
Suggest.prototype.SearchResult = function(txt, xml){
if(document.getElementById("findContent")){
var xmlDoc = xml.documentElement;
try{
var result = eval(xmlDoc.getElementsByTagName("result")[0].firstChild.nodeValue);
if(result){
var responseText = xmlDoc.getElementsByTagName("name");
this.FillResult(responseText);
}else{
this.Hidden();
}
}catch(ex){
}
}else{
alert("未找到容器!");
}
}
Suggest.prototype.FillResult = function(aryResult){
this.result = 0;
var findList = document.getElementById("findList");
var findListArray = findList.getElementsByTagName("li");
if(findListArray.length > 0){
for(var i = findListArray.length - 1; i >= 0; i--){
findList.removeChild(findListArray[i]);
}
}
this.result = aryResult.length;
for(var i = 0; i < this.result; i++){
var This = this;
var findLI = document.createElement("li");
findLI.id = "li" + i;
findLI.cursor = i;
findLI.style.color = "#999";
findLI.style.cursor = "pointer";
findLI.style.fontSize = "14px";
findLI.style.textAlign = "left";
findLI.style.lineHeight = "22px";
findLI.style.padding = "0px 4px 0px 4px";
findLI.style.width = (this.layerWidth - 2) + "px";
findLI.onclick = function(){This.cursor = this.cursor;This.AddToInput(this);};
findLI.onmouseover = function(){this.style.background = "#D0F5FF";This.cursor = this.cursor;};
findLI.onmouseout = function(){this.style.background = "#fff";this.style.color = "#999";};
findLI.innerHTML = aryResult[i].firstChild.nodeValue.replace(new RegExp(this.keyword,"gi"),"<span style='color: red;'>" + this.keyword + "</span>");
findList.appendChild(findLI);
}
findList.style.height = (this.result > 10 ? 220 : 22 * this.result) + "px";
document.getElementById("findContent").style.display = "block";
}
Suggest.prototype.CreateElement = function(objParent){
if(!objParent){alert("object not found!");return (false);}
var This = this;
if(this.objParent && this.objParent != objParent){this.Hidden();}
this.objParent = objParent;
this.objParent.onkeyup = function(event){This.ReSearch(event);};
this.objParent.onkeydown = function(event){This.MoveCursor(event);};
//this.objParent.onblur = function(){This.taskID = setTimeout(function(){This.Hidden();}, 1000);};
this.layerWidth = this.objParent.offsetWidth;
if(!document.getElementById("findContent")){
var findContent = document.createElement("div");
findContent.id = "findContent";
//findContent.style.width = (this.layerWidth - 2) + "px";
findContent.style.zIndex = "100";
findContent.style.position = "absolute";
findContent.style.background = "#fff";
findContent.style.border = "1px solid #999";
findContent.style.display = "none";
var findList = document.createElement("ul");
findList.id = "findList";
//findList.style.width = (this.layerWidth - 2) + "px";
findList.style.listStyle = "none";
findList.style.margin = "0px 0px 0px 0px";
findList.style.padding = "0px 0px 0px 0px";
findList.style.height = "220px";
findList.style.overflowX = "hidden";
findList.style.overflowY = "auto";
var divAD = document.createElement("div");
divAD.style.height = "22px";
divAD.style.lineHeight = "22px";
divAD.style.textAlign = "center";
divAD.style.paddingRight = "5px";
divAD.style.background = " #E1E1E1";
divAD.innerHTML = "<a href=\"javascript:void(0);\" style=\"text-decoration: underline; color: #369;\" onclick=\"Suggest.Hidden();\">关闭</a>";
findContent.appendChild(findList);
findContent.appendChild(divAD);
document.body.appendChild(findContent);
this.Position(findContent);
}
else{
this.Position(document.getElementById("findContent"));
}
clearTimeout(this.taskID);
}
Suggest.prototype.Position = function(findContent){
document.getElementById("findList").style.width = (this.layerWidth - 2) + "px";
document.getElementById("findContent").style.width = (this.layerWidth - 2) + "px";
var selectedPosX = 2;
var selectedPosY = -1;
theElement = this.objParent;
while(theElement != null){
selectedPosX += theElement.offsetLeft;
selectedPosY += theElement.offsetTop;
theElement = theElement.offsetParent;
}
findContent.style.left = selectedPosX + "px";
findContent.style.top = selectedPosY + this.objParent.offsetHeight + "px";
}
Suggest.prototype.AddToInput = function(el){
this.objParent.value = el.innerHTML.replace(/<[^>]+>/gi,"");
this.Hidden();
//this.objParent.form.submit();
}
Suggest.prototype.MoveCursor = function(event){
var e = event || window.event;
switch(e.keyCode){
case 38:
if(this.result > 0){this.MoveToCurrent(-1);}
break;
case 40:
if(this.result > 0){this.MoveToCurrent(1);}
break;
case 13:
if(this.result > 0){if(this.cursor < 0){this.Hidden();}else{this.AddToInput(this.SelectedValue());}return (false);}
break;
case 27:
this.Hidden();
break;
default:
return (false);
break;
}
}
Suggest.prototype.ReSearch = function(event){
var e = event || window.event;
if(e.keyCode == 38 || e.keyCode == 40){return (false);}
this.objParent = e.target || e.srcElement;
this.cursor = -1;
if(this.objParent.value.replace(/(^\s*)|(\s*$)/g, "") != ""){this.Search(this.objParent);}else{this.Hidden();}
}
Suggest.prototype.MoveToCurrent = function(step){
var el1 = document.getElementById("li" + this.cursor);
if(el1){el1.style.background = "#fff";el1.style.color = "#999";}
this.cursor += step;
if(this.cursor < 0){this.cursor = 0;}
if(this.cursor >= this.result){this.cursor = this.result - 1;}
var el2 = document.getElementById("li" + this.cursor);
if(el2){el2.style.background = "#D0F5FF";el2.style.color = "#999";}
this.startIndex += step;
if(this.startIndex > 9){this.startIndex = 9;}
if(this.startIndex < 0){this.startIndex = 0;}
//document.getElementById("startIndex").innerHTML = this.startIndex;
if(this.cursor > 9){
if(this.startIndex == 0){document.getElementById("findList").scrollTop = (this.cursor) * 22;}
if(this.startIndex == 9){document.getElementById("findList").scrollTop = (this.cursor - 9) * 22;}
}else{
document.getElementById("findList").scrollTop = 0;
}
}
Suggest.prototype.SelectedValue = function(){
return document.getElementById("findList").getElementsByTagName("li")[this.cursor];
}
Suggest.prototype.Hidden = function(){
this.cursor = -1;
if(document.getElementById("findContent")){
document.getElementById("findContent").style.display = "none";
//document.body.removeChild(findContent)
}
}
<!--#include file="conn.asp"-->
<%
set rs=server.createobject("adodb.recordset")
Response.ContentType="text/xml"
k=trim(request("keyword"))
a=cint(request("a"))
sql="select chanpinname from cangku where chanpinname like '%"&k&"%' "
rs.open sql,conn,1,3
str="<?xml version=""1.0"" encoding=""gb2312""?>"
str=str&"<data>"
If rs.EOF or rs.BOF Then
str=str&"<result>false</result>"
Else
str=str&"<result>true</result>"
Do While Not rs.EOF
str=str&"<name>"
str=str&"<![CDATA["&rs("chanpinname")&"]]>"
str=str&"</name>"
rs.MoveNext
Loop
End If
str=str&"</data>"
rs.close
response.write str
%>
suggest.js 页面
function Suggest(){
this.objParent = null;
this.delaySec = 100;
this.cursor = -1;
this.objAjax = null;
this.layerWidth = 200;
this.result = 0;
this.taskID = null;
this.keyword = null;
this.url = null;
this.startIndex = 0;
}
Suggest.prototype.Search = function(objParent, url){
var This = this;
this.CreateElement(objParent);
this.keyword = this.objParent.value.replace(/(^\s*)|(\s*$)/g, "");
if(url){this.url = url;}
if(this.keyword != ""){
if(this.taskID){clearTimeout(this.taskID);this.taskID = null;}
if(!this.objAjax){this.objAjax = new Ajax();}else if(this.objAjax.readyState != 0){this.objAjax.abort();}
this.objAjax.clearParams();
this.objAjax.addParams("keyword", this.keyword);
this.objAjax.OnComplete = function(txt, xml){This.SearchResult(txt, xml);};
this.taskID = setTimeout(function(){This.objAjax.CallBack("GET",This.url);}, this.delaySec);
}
}
Suggest.prototype.SearchResult = function(txt, xml){
if(document.getElementById("findContent")){
var xmlDoc = xml.documentElement;
try{
var result = eval(xmlDoc.getElementsByTagName("result")[0].firstChild.nodeValue);
if(result){
var responseText = xmlDoc.getElementsByTagName("name");
this.FillResult(responseText);
}else{
this.Hidden();
}
}catch(ex){
}
}else{
alert("未找到容器!");
}
}
Suggest.prototype.FillResult = function(aryResult){
this.result = 0;
var findList = document.getElementById("findList");
var findListArray = findList.getElementsByTagName("li");
if(findListArray.length > 0){
for(var i = findListArray.length - 1; i >= 0; i--){
findList.removeChild(findListArray[i]);
}
}
this.result = aryResult.length;
for(var i = 0; i < this.result; i++){
var This = this;
var findLI = document.createElement("li");
findLI.id = "li" + i;
findLI.cursor = i;
findLI.style.color = "#999";
findLI.style.cursor = "pointer";
findLI.style.fontSize = "14px";
findLI.style.textAlign = "left";
findLI.style.lineHeight = "22px";
findLI.style.padding = "0px 4px 0px 4px";
findLI.style.width = (this.layerWidth - 2) + "px";
findLI.onclick = function(){This.cursor = this.cursor;This.AddToInput(this);};
findLI.onmouseover = function(){this.style.background = "#D0F5FF";This.cursor = this.cursor;};
findLI.onmouseout = function(){this.style.background = "#fff";this.style.color = "#999";};
findLI.innerHTML = aryResult[i].firstChild.nodeValue.replace(new RegExp(this.keyword,"gi"),"<span style='color: red;'>" + this.keyword + "</span>");
findList.appendChild(findLI);
}
findList.style.height = (this.result > 10 ? 220 : 22 * this.result) + "px";
document.getElementById("findContent").style.display = "block";
}
Suggest.prototype.CreateElement = function(objParent){
if(!objParent){alert("object not found!");return (false);}
var This = this;
if(this.objParent && this.objParent != objParent){this.Hidden();}
this.objParent = objParent;
this.objParent.onkeyup = function(event){This.ReSearch(event);};
this.objParent.onkeydown = function(event){This.MoveCursor(event);};
//this.objParent.onblur = function(){This.taskID = setTimeout(function(){This.Hidden();}, 1000);};
this.layerWidth = this.objParent.offsetWidth;
if(!document.getElementById("findContent")){
var findContent = document.createElement("div");
findContent.id = "findContent";
//findContent.style.width = (this.layerWidth - 2) + "px";
findContent.style.zIndex = "100";
findContent.style.position = "absolute";
findContent.style.background = "#fff";
findContent.style.border = "1px solid #999";
findContent.style.display = "none";
var findList = document.createElement("ul");
findList.id = "findList";
//findList.style.width = (this.layerWidth - 2) + "px";
findList.style.listStyle = "none";
findList.style.margin = "0px 0px 0px 0px";
findList.style.padding = "0px 0px 0px 0px";
findList.style.height = "220px";
findList.style.overflowX = "hidden";
findList.style.overflowY = "auto";
var divAD = document.createElement("div");
divAD.style.height = "22px";
divAD.style.lineHeight = "22px";
divAD.style.textAlign = "center";
divAD.style.paddingRight = "5px";
divAD.style.background = " #E1E1E1";
divAD.innerHTML = "<a href=\"javascript:void(0);\" style=\"text-decoration: underline; color: #369;\" onclick=\"Suggest.Hidden();\">关闭</a>";
findContent.appendChild(findList);
findContent.appendChild(divAD);
document.body.appendChild(findContent);
this.Position(findContent);
}
else{
this.Position(document.getElementById("findContent"));
}
clearTimeout(this.taskID);
}
Suggest.prototype.Position = function(findContent){
document.getElementById("findList").style.width = (this.layerWidth - 2) + "px";
document.getElementById("findContent").style.width = (this.layerWidth - 2) + "px";
var selectedPosX = 2;
var selectedPosY = -1;
theElement = this.objParent;
while(theElement != null){
selectedPosX += theElement.offsetLeft;
selectedPosY += theElement.offsetTop;
theElement = theElement.offsetParent;
}
findContent.style.left = selectedPosX + "px";
findContent.style.top = selectedPosY + this.objParent.offsetHeight + "px";
}
Suggest.prototype.AddToInput = function(el){
this.objParent.value = el.innerHTML.replace(/<[^>]+>/gi,"");
this.Hidden();
//this.objParent.form.submit();
}
Suggest.prototype.MoveCursor = function(event){
var e = event || window.event;
switch(e.keyCode){
case 38:
if(this.result > 0){this.MoveToCurrent(-1);}
break;
case 40:
if(this.result > 0){this.MoveToCurrent(1);}
break;
case 13:
if(this.result > 0){if(this.cursor < 0){this.Hidden();}else{this.AddToInput(this.SelectedValue());}return (false);}
break;
case 27:
this.Hidden();
break;
default:
return (false);
break;
}
}
Suggest.prototype.ReSearch = function(event){
var e = event || window.event;
if(e.keyCode == 38 || e.keyCode == 40){return (false);}
this.objParent = e.target || e.srcElement;
this.cursor = -1;
if(this.objParent.value.replace(/(^\s*)|(\s*$)/g, "") != ""){this.Search(this.objParent);}else{this.Hidden();}
}
Suggest.prototype.MoveToCurrent = function(step){
var el1 = document.getElementById("li" + this.cursor);
if(el1){el1.style.background = "#fff";el1.style.color = "#999";}
this.cursor += step;
if(this.cursor < 0){this.cursor = 0;}
if(this.cursor >= this.result){this.cursor = this.result - 1;}
var el2 = document.getElementById("li" + this.cursor);
if(el2){el2.style.background = "#D0F5FF";el2.style.color = "#999";}
this.startIndex += step;
if(this.startIndex > 9){this.startIndex = 9;}
if(this.startIndex < 0){this.startIndex = 0;}
//document.getElementById("startIndex").innerHTML = this.startIndex;
if(this.cursor > 9){
if(this.startIndex == 0){document.getElementById("findList").scrollTop = (this.cursor) * 22;}
if(this.startIndex == 9){document.getElementById("findList").scrollTop = (this.cursor - 9) * 22;}
}else{
document.getElementById("findList").scrollTop = 0;
}
}
Suggest.prototype.SelectedValue = function(){
return document.getElementById("findList").getElementsByTagName("li")[this.cursor];
}
Suggest.prototype.Hidden = function(){
this.cursor = -1;
if(document.getElementById("findContent")){
document.getElementById("findContent").style.display = "none";
//document.body.removeChild(findContent)
}
}
作者: yacity 发布时间: 2010-10-13
ajax.js 页面
function Ajax(){
this.ajax = this.CreateObject();
this.requestParamsArray = new Array();
this.requestParams = null;
this.readyState = 0;
this.async = true;
}
Ajax.prototype.CreateObject = function(){
var xmlhttp = false;
try {xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (othermicrosoft) {
try {xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (otherbrowser) {
try {xmlhttp = new XMLHttpRequest();
} catch (failed){
xmlhttp = false;}
}
}
return xmlhttp;
}
Ajax.prototype.addParams = function(pName,pValue){
var theName = pName;
var theValue = escape(pValue);
this.requestParamsArray.push(theName + "=" + theValue);
this.requestParams = this.requestParamsArray.join("&");
}
Ajax.prototype.clearParams = function(){
this.requestParamsArray = new Array();
this.requestParams = null;
}
Ajax.prototype.CallBack = function(Method,Url,Async){
if (this.ajax && typeof(this.ajax) != "undefined") {
if (this.ajax.readyState == 4 || this.ajax.readyState == 0) {
if (typeof(Async) == "boolean") { this.async = Async; }
if (this.async) {
var This = this;
this.ajax.onreadystatechange = function(){This.ReadyStateChange();};
}
this.ajax.open(Method,Url + "?" + this.requestParams,this.async);
//this.ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
//this.ajax.send(this.requestParams);
this.ajax.send(null);
}
} else {
document.write("Ajax object not initialized!");
}
}
Ajax.prototype.ReadyStateChange = function(){
this.readyState = this.ajax.readyState;
if (this.ajax.readyState == 4) {
if (this.ajax.status == 200) {
this.OnComplete(unescape(this.ajax.responseText),this.ajax.responseXML);
} else {
this.OnError(this.ajax.status);
}
}
}
Ajax.prototype.abort = function(){
this.ajax.abort();
}
Ajax.prototype.OnComplete = function(){
//some code here
}
Ajax.prototype.OnError = function(){
//some code here
}
conn.asp 页面
<%@ LANGUAGE = VBScript CodePage = 936%>
<%
'Option Explicit
Db = "dzqfsl.mdb"
'ConnStr = "driver={Microsoft Access Driver (*.mdb)};dbq= " & Server.MapPath(Db)
ConnStr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(Db)
On Error Resume Next
Set conn = Server.CreateObject("ADODB.Connection")
conn.open ConnStr
If Err Then
err.Clear
Set Conn = Nothing
Response.Write " Error......"
Response.End
End If
%>
数据库结构如下:
客户表(Customers)
Userid 客户id
Company 公司名称
Lianxiren 联系人
Sheng 省份
Shi 市
Zhen 镇
Dizhi 地址
Youbian 邮编
Tel 电话
Tel2 电话
Tel3 电话
Beizhu beizhu
仓库表(cangku)
Id 产品 id
Chanpinname 产品名称
Guie 产品规格
Danwei 单位
Shuliang 数量
Danjia 单价
Zonger 总额
Beizhu 备注
可以输入 “一级红绳”“黑地膜” 进行测试。
function Ajax(){
this.ajax = this.CreateObject();
this.requestParamsArray = new Array();
this.requestParams = null;
this.readyState = 0;
this.async = true;
}
Ajax.prototype.CreateObject = function(){
var xmlhttp = false;
try {xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (othermicrosoft) {
try {xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (otherbrowser) {
try {xmlhttp = new XMLHttpRequest();
} catch (failed){
xmlhttp = false;}
}
}
return xmlhttp;
}
Ajax.prototype.addParams = function(pName,pValue){
var theName = pName;
var theValue = escape(pValue);
this.requestParamsArray.push(theName + "=" + theValue);
this.requestParams = this.requestParamsArray.join("&");
}
Ajax.prototype.clearParams = function(){
this.requestParamsArray = new Array();
this.requestParams = null;
}
Ajax.prototype.CallBack = function(Method,Url,Async){
if (this.ajax && typeof(this.ajax) != "undefined") {
if (this.ajax.readyState == 4 || this.ajax.readyState == 0) {
if (typeof(Async) == "boolean") { this.async = Async; }
if (this.async) {
var This = this;
this.ajax.onreadystatechange = function(){This.ReadyStateChange();};
}
this.ajax.open(Method,Url + "?" + this.requestParams,this.async);
//this.ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
//this.ajax.send(this.requestParams);
this.ajax.send(null);
}
} else {
document.write("Ajax object not initialized!");
}
}
Ajax.prototype.ReadyStateChange = function(){
this.readyState = this.ajax.readyState;
if (this.ajax.readyState == 4) {
if (this.ajax.status == 200) {
this.OnComplete(unescape(this.ajax.responseText),this.ajax.responseXML);
} else {
this.OnError(this.ajax.status);
}
}
}
Ajax.prototype.abort = function(){
this.ajax.abort();
}
Ajax.prototype.OnComplete = function(){
//some code here
}
Ajax.prototype.OnError = function(){
//some code here
}
conn.asp 页面
<%@ LANGUAGE = VBScript CodePage = 936%>
<%
'Option Explicit
Db = "dzqfsl.mdb"
'ConnStr = "driver={Microsoft Access Driver (*.mdb)};dbq= " & Server.MapPath(Db)
ConnStr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(Db)
On Error Resume Next
Set conn = Server.CreateObject("ADODB.Connection")
conn.open ConnStr
If Err Then
err.Clear
Set Conn = Nothing
Response.Write " Error......"
Response.End
End If
%>
数据库结构如下:
客户表(Customers)
Userid 客户id
Company 公司名称
Lianxiren 联系人
Sheng 省份
Shi 市
Zhen 镇
Dizhi 地址
Youbian 邮编
Tel 电话
Tel2 电话
Tel3 电话
Beizhu beizhu
仓库表(cangku)
Id 产品 id
Chanpinname 产品名称
Guie 产品规格
Danwei 单位
Shuliang 数量
Danjia 单价
Zonger 总额
Beizhu 备注
可以输入 “一级红绳”“黑地膜” 进行测试。
作者: yacity 发布时间: 2010-10-13
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28