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,聯接數據庫functionvar 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);
}
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,制做下拉菜單選項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
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
調用的時候: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>