form name="form1" method="post" action="pic_search.asp">
〈table width="100%" border="0" cellspacing="0" cellpadding="0">
〈tr>
〈td width="80%">电子名片搜索
〈input size="24" name="text1" type="text" id="text1" onfocus=this.select()
onclick="if(this.value=='请输入要查找的内容'){this.value='';}" onmouseover=this.focus() value='请输入要查找的内容';"> 〈select name="Field" size="1" id="Field" onChange="document.form1.text2.value=this.options[this.selectedIndex].value;">
〈option value="username">姓名〈/option>
〈option value="usertel">电话〈/option>
〈option value="usertell">手机〈/option>
〈option value="userwork">职位〈/option>
〈option value="useradd">地址〈/option>
〈/select>
〈input type=hidden name="text2">
〈/td>
〈td width="20%">〈input name="imageField" type="image" src="../photo/searchbutton.gif" width="64" height="24"></td>
〈/tr>
〈/table>
〈/form>
以上客户端代码修改后
<%
Dim sql
Select Case Request.Form("text2")
Case "username"
sql="select * from [table] where "&Request.Form("text2")&"='"&Request.Form("text1")&"'"
Case "usertel"
sql="select * from [table] where "&Request.Form("text2")&"="&Request.Form("text1")
Case "usertell"
sql="select * from [table] where "&Request.Form("text2")&"="&Request.Form("text1")
Case "userwork"
sql="select * from [table] where "&Request.Form("text2")&"='"&Request.Form("text1")&"'"
Case "useradd"
sql="select * from [table] where "&Request.Form("text2")&"='"&Request.Form("text1")&"'"
End Select
%>
以上是服务器端代码。
〈table width="100%" border="0" cellspacing="0" cellpadding="0">
〈tr>
〈td width="80%">电子名片搜索
〈input size="24" name="text1" type="text" id="text1" onfocus=this.select()
onclick="if(this.value=='请输入要查找的内容'){this.value='';}" onmouseover=this.focus() value='请输入要查找的内容';"> 〈select name="Field" size="1" id="Field" onChange="document.form1.text2.value=this.options[this.selectedIndex].value;">
〈option value="username">姓名〈/option>
〈option value="usertel">电话〈/option>
〈option value="usertell">手机〈/option>
〈option value="userwork">职位〈/option>
〈option value="useradd">地址〈/option>
〈/select>
〈input type=hidden name="text2">
〈/td>
〈td width="20%">〈input name="imageField" type="image" src="../photo/searchbutton.gif" width="64" height="24"></td>
〈/tr>
〈/table>
〈/form>
以上客户端代码修改后
<%
Dim sql
Select Case Request.Form("text2")
Case "username"
sql="select * from [table] where "&Request.Form("text2")&"='"&Request.Form("text1")&"'"
Case "usertel"
sql="select * from [table] where "&Request.Form("text2")&"="&Request.Form("text1")
Case "usertell"
sql="select * from [table] where "&Request.Form("text2")&"="&Request.Form("text1")
Case "userwork"
sql="select * from [table] where "&Request.Form("text2")&"='"&Request.Form("text1")&"'"
Case "useradd"
sql="select * from [table] where "&Request.Form("text2")&"='"&Request.Form("text1")&"'"
End Select
%>
以上是服务器端代码。