常用的asp代碼和javascript代碼

1,js打開一個新的窗口
function opencenterwin(page,winName,w,h){
  
var sw = screen.availWidth;
  
var sh = screen.availHeight;
  newwin
=this.open(page,winName,["toolbar=0,menubar=0,location=0,scrollbars=0,resize=0,width="+w+",height="+h+",top="+((sh-h-20)*.5)+",left="+((sw-w-30)*.5)]);
}
function opencenterwin1(page,winName,w,h){
  
var sw = screen.availWidth;
  
var sh = screen.availHeight;
  newwin
=this.open(page,winName,"toolbar=no,menubar=no,resizable=yes,scrollbars=yes,width="+w+",height="+h+",top="+((sh-h-20)*.5)+",left="+((sw-w-30)*.5),false);
}
2,聯接數據庫function
Function Opendb(conn_to)
    Application.Lock

    
Dim conn
    
Set conn = Server.CreateObject("ADODB.Connection")
    conn.ConnectionTimeout 
= 50
    conn.CommandTimeout 
= 120
    
if UCase(conn_to)="MSC" then
    connString 
= "Driver={sql server};uid=mscuser;pwd=;database=prs_msc;server="+strIP
    
else
      connString 
= "Driver={sql server};uid=apuser;pwd=prosperous;database=emsc;server="+strIP
  
end if
  conn.open connString
    
Set Opendb = conn

    Application.UnLock
End Function
3,制做下拉菜單選項
function factory_combobox(factory_id_selected,show_all)
  
if show_all then
    factory_combobox
="<option value=''"
    
if factory_id_selected="" then factory_combobox=factory_combobox&" selected"
    factory_combobox
=factory_combobox&">(全部)</option>"
  
else
    factory_combobox
=""
  
end if
  
set conn_factory=opendb("EMSC")
  
set rs_factory=conn_factory.execute("select * from sis_factory")
  
do while not rs_factory.eof
    factory_combobox
=factory_combobox+"<option value='"&rs_factory("factory_id")&"'"
    
if factory_id_selected=cstr(rs_factory("factory_id")) then factory_combobox=factory_combobox&" selected"
    factory_combobox
=factory_combobox+">"&rs_factory("factory_name")&"</option>"
    rs_factory.movenext
  
loop
  rs_factory.close
  conn_factory.close
end function
調用的時候:
<select name="factory_id"><%=factory_combobox(request("factory_id"),true)%></select>

申明

非源创博文中的内容均收集自网上,若有侵权之处,请及时联络,我会在第一时间内删除.再次说声抱歉!!!

博文欢迎转载,但请给出原文连接。

原文地址:https://www.cnblogs.com/Athrun/p/578480.html