📄 city_edit.asp
字号:
<!--#include file="../Include/AdoConn.asp"-->
<%
dim tableName '下面函数的入口参数,表名
dim KeyWord '各表主关键字名称
dim KeyType '主键类型,自动增加型为"空",字符型为 " ' "
dim Num '保存取得的各字段个数
tableName="xt_td_city"
KeyWord="城市编码"
KeyType=""
Num=18
redim var(Num)
for i=0 to Num
var(i)=""
next
code=request.querystring("code")'修改
if code<>"" then
set rst=server.createobject("adodb.recordset")
strsql="select * from "&tableName&" where "&KeyWord&"="&KeyType&code&KeyType
rst.open strsql,conn
if not rst.eof then
for i=0 to rst.fields.count-1
var(i)=rst(i)
next
end if
rst.Close
set rst=nothing
end if
if Request.QueryString ("submit")="submit" then'是否是提交状态
set rst=server.CreateObject ("adodb.recordset")
strsql="select top 1 * from "&tableName
rst.Open strsql,conn
N=Num
code=Request.Form ("code")
if code<>"" then'修改
for i=1 to N
strSet=strSet&rst(i).name&"="&"'"&Request.Form(i)&"'"
if i<>N then
strSet=strSet+","
end if
next
strsql="update "&tableName&" set "&strSet&" where "&KeyWord&"="&KeyType&code&KeyType
conn.execute (strsql)
info="您已提交修改成功!"
else'新增
'''''''''''''''''''''检查数据库内是否有此城市"判断中文名"
set rst2=server.CreateObject ("ADODB.recordset")
StrSQL="select 中文城市名 from "&tableName&" where 中文城市名='"&Request.Form (1)&"'"
rst2.Open strsql,conn,3,2
if not rst2.EOF then
%>
<script Language="JavaScript">
<!--
alert("此城市已注册!");
history.back(-1);
// -->
</script>
<%
Response.End
end if
rst2.Close
set rst2=nothing
'''''''''''''''''''''检查结束
dim strTitle,strValue'记录自动生成form\rst.fields语句的变量
strTitle=""
strValue=""
for i=1 to N
strTitle=strTitle&rst(i).name
strValue=strValue&"'"&Request.Form(i)&"'"
if i<>N then
strTitle=strTitle+","
strValue=strValue+","
end if
next
strsql="insert into "&tableName&"("&strTitle&")values("&strValue&")"
conn.execute (strsql)
info="您已提交成功!"
end if
rst.Close
set rst=nothing
end if
%>
<html>
<head>
<title>注册城市</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="/Css/All.css">
<script language="javascript">
ArrayString=new Array(0,"textfield1","中文城市名称不能为空!");
</script>
<script language="javascript" src="../js/checkForm.js"></script>
<script language="javascript" src="../js/Check_email_num.js"></script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center"><font size="2"><%=info%></font></td>
</tr>
</table>
<table width="500" border="0" cellspacing="0" cellpadding="0" align="center" background="../Images/title_edit.gif">
<tr >
<td width="199" height="30"> </td>
<td width="112" height="30" align="center"><font size="2">注 册 城 市</font></td>
<td width="189" height="30"><font size="2"> </font></td>
</tr>
</table>
<table width="500" border="0" cellspacing="0" cellpadding="0" align="center" class="snd">
<form name="form1" method="post" action="city_submit.asp" enctype="multipart/form-data" onsubmit="return CheckForm(this)">
<tr>
<td width="24" align="right"><font size="2"> </font></td>
<td width="55" align="right"><font size="2"> </font></td>
<td width="28" align="center"><font size="2"> </font></td>
<td width="250"><font size="2"> </font></td>
<td width="119"><font size="2"> </font></td>
<td width="24"><font size="2"> </font></td>
</tr>
<tr>
<td width="24" align="right"><font size="2"> </font></td>
<td width="55" align="right"><font size="2">城市名称</font></td>
<td width="28" align="center"><font size="2">(中)</font></td>
<td width="250">
<font size="2">
<input type="text" name="textfield1" size="20" maxlength="20" value="<%=var(1)%>">
**</font> </td>
<td width="119"><font size="2">(**为必填项,下同)</font></td>
<td width="24"><font size="2"> </font></td>
</tr>
<tr>
<td width="24" align="right"><font size="2"> </font></td>
<td width="55" align="right"><font size="2"> </font></td>
<td width="28" align="center"><font size="2">(韩)</font></td>
<td width="250">
<font size="2">
<input type="text" name="textfield2" size="20" maxlength="20" value="<%=var(2)%>">
</font>
</td>
<td width="119"><font size="2"> </font></td>
<td width="24"><font size="2"> </font></td>
</tr>
<tr>
<td width="24" align="right"><font size="2"> </font></td>
<td width="55" align="right"><font size="2">所在省</font></td>
<td width="28" align="center"><font size="2"> </font></td>
<td width="250">
<font size="2">
<select name="textfield3">
<%
'取出所有省
set rst1=server.createObject("adodb.recordset")
strsql="select * from xt_td_sheng order by 中文省名"
rst1.open strsql,conn,3,2
if rst1.RecordCount<>0 then
for i=1 to rst1.RecordCount
%>
<option value="<%=rst1("中文省名")%>" <%if var(3)=rst1("中文省名") then response.write "selected" end if%>><%=rst1("中文省名")%></option>
<%rst1.MoveNext
next
end if
rst1.close
%>
</select>
**</font> </td>
<td width="119"><font size="2"> </font></td>
<td width="24"><font size="2"> </font></td>
</tr>
<tr>
<td width="24" align="right"><font size="2"> </font></td>
<td width="55" align="right"><font size="2">区号</font></td>
<td width="28" align="center"><font size="2"> </font></td>
<td width="250">
<font size="2">
<input type="text" name="textfield4" size="20" maxlength="4" value="<%=var(4)%>">
</font>
</td>
<td width="119"><font size="2"> </font></td>
<td width="24"><font size="2"> </font></td>
</tr>
<tr>
<td width="24" align="right"><font size="2"> </font></td>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -