Hi
The problem is, when the (html) page loads all records (around 1000) are written out. The html and asp codes are below.
I would like no records to be written out until the search parameters are enetered.
TIA
Webflex
HTML
ASP
The problem is, when the (html) page loads all records (around 1000) are written out. The html and asp codes are below.
I would like no records to be written out until the search parameters are enetered.
TIA
Webflex
HTML
Code:
<html>
<head>
<title>Employee Directory</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<LINK REL=STYLESHEET HREF="[URL unfurl="true"]http://blahblah.css"[/URL] TYPE="text/css">
</head>
<body>
{Header}
<table>
<tr>
<td valign="top">
<!--BeginFormEmpMonth-->
<table border="0" cellspacing="2" cellpadding="0">
<!--BeginDListEmpMonth-->
<!--EndDListEmpMonth-->
<!--BeginEmpMonthNoRecords-->
<tr>
<td colspan="1" > </td>
</tr>
<!--EndEmpMonthNoRecords-->
</table>
<!--EndFormEmpMonth-->
</td>
<td valign="top">
<!--BeginFormSearch--><form method="GET" action="{ActionPage}" name="Search">
<table border="0" cellspacing="2" cellpadding="0">
<tr>
<td align="center" bgcolor="#FFBB55" colspan="2"><a name="Search"><font style="font-size: 12pt; color: #FFFFFF; font-family: Arial, Tahoma, Verdana, Helvetica; font-weight: bold">Search</font></a></td>
</tr>
<tr>
<td bgcolor="#FFDD00"><font style="font-size: 10pt; color: #000000; font-family: Arial, Tahoma, Verdana, Helvetica">Department</font></td>
<td >
<select name="dep_id">
<option value="{ID}">{Value}</option>
</select>
</td>
</tr>
<tr>
<td bgcolor="#FFDD00"><font style="font-size: 10pt; color: #000000; font-family: Arial, Tahoma, Verdana, Helvetica">Name</font></td>
<td >
<input type="text" name="name" maxlength="15" value="{name}" size="15">
</td>
</tr>
<tr>
<td bgcolor="#FFDD00"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Telephone</font></td>
<td >
<input type="text" name="work_phone" maxlength="50" value="{work_phone}" size="15">
</td>
</tr>
<tr>
<td bgcolor="#FFDD00"><font style="font-size: 10pt; color: #000000; font-family: Arial, Tahoma, Verdana, Helvetica">Initials</font></td>
<td >
<input type="text" name="email" maxlength="50" value="{email}" size="15">
</td>
</tr>
<tr>
<td align="right" colspan="3">
<input type="submit" value="Search">
</td>
</tr>
</table>
</form><!--EndFormSearch-->
</td>
</tr>
</table>
<table>
<tr>
<td valign="top">
<!--BeginFormGrid--><table border="0" cellspacing="2" cellpadding="0">
<tr>
<td align="center" bgcolor="#FFBB55" colspan="5"><a name="Grid"><font style="font-size: 12pt; color: #FFFFFF; font-family: Arial, Tahoma, Verdana, Helvetica; font-weight: bold">CSOL
Directory</font></a></td>
</tr>
<tr>
<td bgcolor="#000000"><a href="{FileName}?{FormParams}FormGrid_Sorting=1&FormGrid_Sorted={Form_Sorting}&"><font style="font-size: 10pt; color: #FFFFFF; font-family: Arial, Tahoma, Verdana, Helvetica; font-weight: bold">Name</font></a></td>
<td bgcolor="#000000"><a href="{FileName}?{FormParams}FormGrid_Sorting=2&FormGrid_Sorted={Form_Sorting}&"><font style="font-size: 10pt; color: #FFFFFF; font-family: Arial, Tahoma, Verdana, Helvetica; font-weight: bold">Title</font></a></td>
<td bgcolor="#000000"><a href="{FileName}?{FormParams}FormGrid_Sorting=3&FormGrid_Sorted={Form_Sorting}&"><font style="font-size: 10pt; color: #FFFFFF; font-family: Arial, Tahoma, Verdana, Helvetica; font-weight: bold">Department</font></a></td>
<td bgcolor="#000000"><a href="{FileName}?{FormParams}FormGrid_Sorting=4&FormGrid_Sorted={Form_Sorting}&"><font style="font-size: 10pt; color: #FFFFFF; font-family: Arial, Tahoma, Verdana, Helvetica; font-weight: bold">Work Phone</font></a></td>
<td bgcolor="#000000"><a href="{FileName}?{FormParams}FormGrid_Sorting=5&FormGrid_Sorted={Form_Sorting}&"><font style="font-size: 10pt; color: #FFFFFF; font-family: Arial, Tahoma, Verdana, Helvetica; font-weight: bold">Initials</font></a></td>
</tr>
<!--BeginDListGrid-->
<tr>
<td ><a href="{name_URLLink}?emp_id={Prm_emp_id}&{TransitParams}"><font style="font-size: 10pt; color: #000000; font-family: Arial, Tahoma, Verdana, Helvetica">{name}</font></a> </td>
<td ><font style="font-size: 10pt; color: #000000; font-family: Arial, Tahoma, Verdana, Helvetica">{title} </font></td>
<td ><font style="font-size: 10pt; color: #000000; font-family: Arial, Tahoma, Verdana, Helvetica">{dep_id} </font></td>
<td ><font style="font-size: 10pt; color: #000000; font-family: Arial, Tahoma, Verdana, Helvetica">{work_phone} </font></td>
<td ><font style="font-size: 10pt; color: #000000; font-family: Arial, Tahoma, Verdana, Helvetica">{email} </font></td>
</tr>
<!--EndDListGrid-->
<!--BeginGridNoRecords-->
<tr><td colspan="5" ><font style="font-size: 10pt; color: #000000; font-family: Arial, Tahoma, Verdana, Helvetica">No records</font></td></tr>
<!--EndGridNoRecords-->
</table>
<!--EndFormGrid-->
</td>
</tr>
</table>
{Footer}
<center>
<font face="Arial"><small></small></font>
</center>
</body>
</html>
ASP
Code:
<!-- #INCLUDE FILE="Common.asp" -->
<%
sFileName = "Default.asp"
sTemplateFileName = "Default.html"
LoadTemplate sAppPath & sTemplateFileName, "main"
LoadTemplate sHeaderFileName, "Header"
SetVar "FileName", sFileName
Header_Show
Grid_Show
Search_Show
EmpMonth_Show
Parse "Header", False
Parse "main", False
Response.write PrintVar("main")
'--------------------------------------------------
Sub Grid_Show()
Dim sWhere
sWhere = ""
sOrder = ""
sSQL = ""
HasParam = false
SetVar "TransitParams", "name=" & ToURL(GetParam("name")) & "&dep_id=" & ToURL(GetParam("dep_id")) & "&email=" & ToURL(GetParam("email")) & "&work_phone=" & ToURL(GetParam("work_phone")) & "&"
SetVar "FormParams", "name=" & ToURL(GetParam("name")) & "&dep_id=" & ToURL(GetParam("dep_id")) & "&email=" & ToURL(GetParam("email")) & "&work_phone=" & ToURL(GetParam("work_phone")) & "&"
' Build WHERE statement
pdep_id = GetParam("dep_id")
if IsNumeric(pdep_id) and not isEmpty(pdep_id) then pdep_id = CLng(pdep_id) else pdep_id = Empty
if not isEmpty(pdep_id) then
HasParam = true
sWhere = sWhere & "e.dep_id=" & pdep_id
end if
pemail = GetParam("email")
if not isEmpty(pemail) then
if not (sWhere = "") then sWhere = sWhere & " and "
HasParam = true
sWhere = sWhere & "e.email like '%" & replace(pemail, "'", "''") & "%'"
end if
pname = GetParam("name")
if not isEmpty(pname) then
if not (sWhere = "") then sWhere = sWhere & " and "
HasParam = true
sWhere = sWhere & "e.name like '%" & replace(pname, "'", "''") & "%'"
end if
pwork_phone = GetParam("work_phone")
if not isEmpty(pwork_phone) then
if not (sWhere = "") then sWhere = sWhere & " and "
HasParam = true
sWhere = sWhere & "e.work_phone like '%" & replace(work_phone, "'", "''") & "%'"
end if
if HasParam then sWhere = " AND (" & sWhere & ")"
' Build ORDER statement
sOrder = " order by e.name Asc"
iSort = GetParam("FormGrid_Sorting")
iSorted = GetParam("FormGrid_Sorted")
sDirection = ""
if IsEmpty(iSort) then
SetVar "Form_Sorting", ""
else
if iSort = iSorted then
SetVar "Form_Sorting", ""
sDirection = " DESC"
sSortParams = "FormGrid_Sorting=" & iSort & "&FormGrid_Sorted=" & iSort & "&"
else
SetVar "Form_Sorting", iSort
sDirection = " ASC"
sSortParams = "FormGrid_Sorting=" & iSort & "&FormGrid_Sorted=" & "&"
end if
if iSort = 1 then sOrder = " order by e.name" & sDirection
if iSort = 2 then sOrder = " order by e.title" & sDirection
if iSort = 3 then sOrder = " order by d.name" & sDirection
if iSort = 4 then sOrder = " order by e.work_phone" & sDirection
if iSort = 5 then sOrder = " order by e.email" & sDirection
end if
' Build full SQL statement
sSQL = "select e.dep_id as e_dep_id, " & _
"e.email as e_email, " & _
"e.emp_id as e_emp_id, " & _
"e.name as e_name, " & _
"e.title as e_title, " & _
"e.work_phone as e_work_phone, " & _
"d.dep_id as d_dep_id, " & _
"d.name as d_name " & _
" from emps e, deps d" & _
" where d.dep_id=e.dep_id "
sSQL = sSQL & sWhere & sOrder
SetVar "SortParams", sSortParams
' Open recordset
openrs rs, sSQL
if rs.eof then
' Recordset is empty
set rs = nothing
SetVar "DListGrid", ""
Parse "GridNoRecords", False
Parse "FormGrid", False
exit sub
end if
' Show main table based on recordset
while not rs.EOF
fldname = GetValue(rs, "e_name")
fldtitle = GetValue(rs, "e_title")
flddep_id = GetValue(rs, "d_name")
fldwork_phone = GetValue(rs, "e_work_phone")
fldemail = GetValue(rs, "e_email")
'fldemail="<a href=mailto:" & fldemail & ">" & fldemail & "</a>"
SetVar "name", ToHTML(fldname)
SetVar "name_URLLink", "EmpDetail.asp"
SetVar "Prm_emp_id", ToURL(GetValue(rs, "e_emp_id"))
SetVar "title", ToHTML(fldtitle)
SetVar "dep_id", ToHTML(flddep_id)
SetVar "work_phone", ToHTML(fldwork_phone)
SetVar "email", ToHTML(fldemail)
Parse "DListGrid", True
rs.MoveNext
wend
set rs = nothing
SetVar "GridNoRecords", ""
Parse "FormGrid", False
End Sub
Sub Search_Show()
SetVar "ActionPage", "Default.asp"
' Set variables with search parameters
flddep_id = GetParam("dep_id")
fldname = GetParam("name")
fldemail = GetParam("email")
fldwork_phone = GetParam("work_phone")
' Show fields
SetVar "LBdep_id", ""
SetVar "ID", ""
SetVar "Value", "All"
Parse "LBdep_id", True
openrs rsdep_id, "select dep_id, name from deps order by 2"
while not rsdep_id.EOF
SetVar "ID", GetValue(rsdep_id, 0) : SetVar "Value", GetValue(rsdep_id, 1)
if cstr(GetValue(rsdep_id, 0)) = cstr(flddep_id) then SetVar "Selected", "SELECTED" else SetVar "Selected", ""
Parse "LBdep_id", True
rsdep_id.MoveNext
wend
set rsdep_id = nothing
SetVar "name", ToHTML(fldname)
SetVar "email", ToHTML(fldemail)
Parse "FormSearch", False
End Sub
Sub EmpMonth_Show()
Dim sWhere
sWhere = ""
sOrder = ""
sSQL = ""
HasParam = false
SetVar "TransitParams", ""
SetVar "FormParams", ""
' Build WHERE statement
sWhere = " WHERE manmonth=1"
' Build full SQL statement
sSQL = "select e.name as e_name, " & _
"e.picture as e_picture " & _
" from emps e "
sSQL = sSQL & sWhere & sOrder
' Open recordset
openrs rs, sSQL
if rs.eof then
' Recordset is empty
set rs = nothing
SetVar "DListEmpMonth", ""
Parse "EmpMonthNoRecords", False
Parse "FormEmpMonth", False
exit sub
end if
' Show main table based on recordset
while not rs.EOF
fldpicture = GetValue(rs, "e_picture")
fldname = GetValue(rs, "e_name")
fldpicture="<img border=0 height=100 width=100 src=images/emps/" & fldpicture & ">"
SetVar "picture", fldpicture
SetVar "name", ToHTML(fldname)
Parse "DListEmpMonth", True
rs.MoveNext
wend
set rs = nothing
SetVar "EmpMonthNoRecords", ""
Parse "FormEmpMonth", False
End Sub
%>
<!-- #INCLUDE FILE="Header.asp" -->