SoFunction
Updated on 2025-04-14

ASP essence source code collection (five-year summary) page 20/20


Combobox with edit function
<HTML>
<HEAD>
<PUBLIC>
<COMPONENT TAGNAME="COMBOBOX">
<PROPERTY NAME="Text" GET="get_Text" PUT="put_Text">
<PROPERTY NAME="Width" GET="get_Width" PUT="put_Width">
<METHOD NAME="SetFocus" INTERNALNAME="htcFocus">
<METHOD NAME="AddItems" INTERNALNAME="htcAddItems">
<EVENT NAME="onYYCenter" ID="idEnter">
<EVENT NAME="onYYCChoose" ID="idChoose">
<ATTACH EVENT="oncontentready" ONEVENT="htcInit()">
</COMPONENT>
</PUBLIC>
<SCRIPT LANGUAGE="javascript">
function htcInit()
{
=document;
=false;
Body_Init();
}
function htcAddItems(items)
{
var i,len;
len=;
for(i=0;i<len;i++)
{(0);}
for(i=0;i<;i++)
{
var o;
if((typeof items[i])=='string')
{
if(!HasTheValue(items,i))
{
o=('OPTION');
=items[i];
(o);
}
}
}
}
function htcFocus()
{
();
}
function get_Text()
{
return ;
}
function put_Text(Value)
{
=Value;
}
function get_Width()
{
return ;
}
function put_Width(Value)
{
=Value;
}
</SCRIPT>
<SCRIPT LANGUAGE="javascript">
function Body_Init()
{
var iRight=;
var iBottom=;
var iLeft=(-18);
='rect(0,'+iRight+','+iBottom+','+iLeft+')';
=();
=();
=0;
=0;
}
function Combo_Select()
{
=[].text;
}
function Text_ChkKey()
{
if(==13)
{
();
}
}
function HasTheValue(sitems,i)
{
var ii;
for(ii=0;ii<i;ii++)
{
if(sitems[ii]==sitems[i])
return true;
}
return false;
}
</SCRIPT>
</HEAD>
<BODY>
<SELECT STYLE="position:absolute;left:0;top:0;" ONCHANGE="Combo_Select()" NAME="pCombo">
</SELECT>
<INPUT STYLE="position:absolute;left:0;top:0;z-index:4000" onKeyPress="Text_ChkKey()" TYPE="TEXT" NAME="pText">
</BODY>
</HTML>
var txtVal = ;
if (comVal == txtVal)
{
= i;
return;
}
}
}
function doResize()
{
if (!)
{
= true;
="none";
="static";
= getLeftPostion();
= getTopPostion() + 1;
= - 16;
= ;
="absolute";
= ;
= ;
= ;
var strRect = "rect(0 "+()+" "+ + " "+( - 2 )+")";
= strRect;
="";
= false;
}
}
function doChange()
{
var idx = ;
var opt = [idx];
= ;
();
();
=-1;
}
function getValue()
{
return ;
}
function doSelectIdx(i)
{
var optLen = ;
if ((i >=0) && (i < optLen))
{
= i;
= [i].text;
return;
}
= "";
}
function focus()
{
();
}
/*resize all combobox when window be resized*/
function resetAllSize()
{
var i;
for (i=0; i < ; i++)
{
theArray[i].doResize();
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function keyPress()
{
var txtStr;
var comStr;
var maxInt = 0;
var defInt = 0;
var defJ;
txtStr = ;
//document.=txtStr;
var j;
for(j=0;j<;j++)
{
comStr = [j].text;
var m;
for(m=0;m<+1;m++)
{
if((m) != (m))
{
maxInt = m;
break;
}
}
if (defInt < maxInt)
{
defInt = maxInt;
defJ = j;
}
}
= defJ;
}
Use asp to combine databases to achieve unlimited pop-up menus (original) - Popular technology
Immortal Bird
Below is a program I wrote, because I think it is better and worth learning from.
So put it on,
If you don't see clearly, please click Quote
If reprinted, please indicate the popular technology forum of Self-Study Network (Immortal Bird QQ 33054474)
Thanks
< !-- #include virtual='Include/' -->
< %
set rs=("")
sql="SELECT menu_name, menu_link, menu_bgcolor, menu_color,id FROM enter_individual WHERE (parent_id = (SELECT id FROM enter_individual WHERE menu_flag = 'root' )) " 'Query to get the root node
sql,conn,1,1
"< table width=100% border=0 cellspacing=1 cellpadding=0 align=center>< tr bgcolor=#3399CC valign=bottom align=center>"
sumnum=
myArray=()
()
width=780/sumnum 'Judge the incrementing pixels of the x-coordinate of the pop-up menu from the number of first-level submenu
dim i
i=0
defaultbgcolor="#3399cc" 'Specify the default background color
defaultcolor="#ffffff" 'Specify the default font color
defaultlink="#" 'Specify the default link
posit_x=0 'x position
flag=1 ' flag, as the menu pop-up direction 1 means right and 0 means left
' myArray(4,6)
while i "< td height=20 bgcolor="&myArray(2,i)&" width="&widd&">< a href="../../&myArray(1,i)&" onmouseover=java script:a"&myArray(4,i)&".='block' onmouseout=java script:a"&myArray(4,i)&".='none' >< font color="&myArray(3,i)&" >"&myArray(0,i)&"< /a>< /td>"
'-----------------------------------------------
i=i+1
Wend
"< /tr>< /table>"
i=0
while i posit_y=100 'y position returns to original position
If i>=(sumnum/2) Then 'If the menu enters the right half, the turn will pop up
flag=0
End If
'Call GetSubMenu function to set the lower menu of this item's first-level menu, using myArray(4,i) that is, the menu id as the id of the div where the lower menu is located
GetSubMenu myArray(4,i),posit_x,posit_y
posit_x=posit_x+widd 'The x coordinate value of the submenu of the next first-level menu is increased by one unit
i=i+1
Wend
'Use the function of the delivery algorithm to the following menu
'parent_id Parent id; posit_x The left position of the pop-up layer; posit_y The position of the pop-up layer away from the above;
Function GetSubMenu(parent_id,posit_x,posit_y)
dim myArray
dim sumnum
dim i
'Query the submenu's lower menu
sql="SELECT menu_name, menu_link, menu_bgcolor, menu_color,id FROM enter_individual WHERE parent_id = "&parent_id&" AND user_id = '"&userid&"'"
sql,conn,1,1
'If the lower menu does not exist, then the number of layers is reduced by one, close the database link, create an empty layer with the parent id as the div id, and then return
If =true Then
level=level-1
()
' parent_id
"< div id='a"&parent_id&"' style='position: absolute; top: 4; left: -1; display: none; width: 0; height: 0'>< /div>"
Else
'If there is a database data fetched and call SetSubMenu to display the menu
sumnum=
myArray=()
()
SetSubMenu myArray,sumnum,parent_id,posit_x,posit_y
'Change the data and call GetSubMenu
i=0
while i< sumnum
posit_y=posi_y*1+20 'Term once posit_y Add one unit,
if level=0 Then 'If the series is reduced to 0, then return to 1
level=1
End If
'If flag=1 Then
'GetSubMenu myArray(4,i),posi_x+level*widd,posi_y-level*20 'Call GetSubMenu x, y coordinate extension level units
'End If
If flag=0 Then
GetSubMenu myArray(4,i),posi_x-level*widd,posi_y-level*20 'Call GetSubMenu x, y coordinate extension level units
Else
GetSubMenu myArray(4,i),posi_x+level*widd,posi_y-level*20 'Call GetSubMenu x, y coordinate extension level units
End If
i=i+1
Wend
End If
End Function
'Set submenu function
'myArray menu data , sumnum array size , parent_id layer id ;
'posit_x The left position of the pop-up layer; posit_y The position of the pop-up layer from above;
Function SetSubMenu (myArray,sumnum,parent_id,posit_x,posit_y)
dim i
parent_&parent_id 'Parent menu id is preceded by a as the id of the layer
hh=sumnum*20 'Array size is multiplied by 20 as the height of the layer
"< DIV onmouseover=java script:"&parent_id&".='block' onmouseout=java script:"&parent_id&".='none' ID='"&parent_id&"' STYLE='position: absolute; top:"&posit_y&"; left:"&posit_x&"; height:"&hh*1&"; width: "&widd&"; display:none;vertical-align: top'>< table width=100% border=0 cellspacing=1 cellpadding=0 >"
i=0
While i
myArray(0,i)=Trim(myArray(0,i))
myArray(1,i)=Trim(myArray(1,i))
myArray(2,i)=Trim(myArray(2,i))
myArray(3,i)=Trim(myArray(3,i))
If myArray(2,i)="" Then
myArray(2,i)=defaultbgcolor
End If
If myArray(3,i)="" Then
myArray(3,i)=defaultcolor
End If
If myArray(1,i)="" Then
myArray(1,i)=defaultlink
End If
"< tr align=center >< td width=100% height=20 bgcolor="&myArray(2,i)&" onmouseover=java script:"&parent_id&".='block';a"&myArray(4,i)&".='block' onmouseout=java script:a"&myArray(4,i)&".='none'>< a href='"&myArray(1,i)&"'>< font color="&myArray(3,i)&" >"&myArray(0,i)&"< /font>< /a>< /td>< /tr>"
i=i+1
Wend
" < /table> < /DIV>"
End Function
Set rs=nothing
()
Set conn=nothing
% >
-------Automatically select text in the text box
<input type="text" name="mtext" size="100" width=20 value="Move the mouse tag up to see:)" onmouseover="focus();select();">
Force ie download code:
Example:
Download source/file
<a href="?n=">
:
<%
= true

dim url
Dim fso,fl,flsize
dim Dname
Dim objStream,ContentType,flName,isre,url1
'********************************************************* The download file name passed in when calling
Dname=trim(request("n"))
‘******************************************************************
If Dname<>"" Then
'********************************************* The server directory where the download file is stored
url=("../source")&"\"&Dname
‘***************************************************
End If
Set fso=("")
Set fl=(url)
flsize=
flName=
Set fl=Nothing
Set fso=Nothing
%>
<%
Set objStream = ("")

= 1
url
Select Case lcase(Right(flName, 4))
Case ".asf"
ContentType = "video/x-ms-asf"
Case ".avi"
ContentType = "video/avi"
Case ".doc"
ContentType = "application/msword"
Case ".zip"
ContentType = "application/zip"
Case ".xls"
ContentType = "application/-excel"
Case ".gif"
ContentType = "image/gif"
Case ".jpg", "jpeg"
ContentType = "image/jpeg"
Case ".wav"
ContentType = "audio/wav"
Case ".mp3"
ContentType = "audio/mpeg3"
Case ".mpg", "mpeg"
ContentType = "video/mpeg"
Case ".rtf"
ContentType = "application/rtf"
Case ".htm", "html"
ContentType = "text/html"
Case ".txt"
ContentType = "text/plain"
Case Else
ContentType = "application/octet-stream"
End Select
"Content-Disposition", "attachment; filename=" & flName
"Content-Length", flsize
= "UTF-8"
= ContentType


()

Set objStream = Nothing
%>
JS determines the correctness of the input date
<script language=javascript>
function strDateTime(str){
var reg = /^(\d{1,4})(-\/)(\d{1,2})\2(\d{1,2})$/;
var r = (reg);
if(r==null)return false;
var d= new Date(r[1], r[3]-1,r[4]);
var newStr=()+r[2]+(()+1)+r[2]+()
return newStr==str
}
alert(strDateTime("2002-1-31"))
alert(strDateTime("2002-1-41"))
</script>
If alert(strDateTime("2002-01-31"))
It is judged illegal
So I wrote it like this
function isDate(str){
if (==0)return true;
var reg = /^(\d{4})(-\/)(0?[1-9]1[0-2])(-\/)(0?[1-9][12][0-9]3[01])$/g;
var r = (str);
if(r==null)return false;
var d = new Date(r[1], r[3]-1,r[5]);
var newStr=()+r[2]+(()+1)+r[2]+()
var reg=/(\/-)(0*)( *)([1-9])/g //(Accept spaces, this can be cancelled)
var t=(reg,'$1$4')
if (newStr==t)return true;
return false;
}
Foreigners' system, data extracted from the database is displayed as? , add the following statement
<%@ Language=VBScript codepage=936 %>
Twenty-eight tips to improve ASP performance and appearance
/china/technet/iis/tips/
Previous page1234567891011121314151617181920Read the full text