Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
[highlight]<input type="text" value="<%=objRS("StaffNo")%>" name="StaffNo"><p>
<input type="text" value="<%=objRS("Location")%>" name="Location">
<input type="text" value="<%=objRS("ManagerNo")%>" name="ManagerNo"><p>[/highlight]
<select name="Course">
<%do while not objRS.eof %>
<option value="<%=objRS("CourseKey")%>"><%=objRS("CourseKey")%>
</option>
<%
objRS.MoveNext
loop
%>
</select>
[highlight]<input type="text" value="<%=objRS("CourseDate")%>" name="CourseDate">
<input type="text" value="<%=objRS("TrainerNo")%>" name="TrainerNo">[/highlight]
[highlight]<input type="text" value="<%=objRS("CourseDate")%>" name="CourseDate">[/highlight]
<%
Dim strSQL, objRS
If [highlight]Len(Request.QueryString("staffNo")) = 0[/highlight] Then
Response.Write "Sorry this staff number does not exist. Please try again."
Else
If Request.QueryString("StaffNo")="" and Request.QueryString("LName")=""[highlight] [/highlight]then
Response.Redirect "name1.asp"
ElseIf Request.QueryString("LName2")="" and Request.QueryString("StaffNo")<>"" then
strSQL = "SELECT * from Staff, Validation where staff.staffno = validation.staffno and staff.staffno = '" & Request.QueryString("StaffNo") & "'"
GetConnection
Set objRS = CreateObject("ADODB.Recordset")
objRS.Open strSQL, Conn
[highlight]'If no records were returned then give them an error message
If objRS.EOF Then
Response.Write "Sorry, the staff number you providd does not appear to exist. Please try again."
Else[/highlight]
%>
<input type="text" value="<%=objRS("LName")%>" name="LName">
<input type="text" value="<%=objRS("FName")%>" name="FName">
<%
[highlight]End If[/highlight]
ElseIf Request.QueryString("LName")<>"" then
strSQL = "SELECT * from Staff, Validation where staff.staffno = validation.staffno and staff.Lname = '" & Request.Querystring("LName") & "' and staff.FName = '" & Request.Querystring("FName") & "'"
%>
<input type="text" value="<%=Request.querystring("LName")%>" name="LName">
<input type="text" value="<%=Request.querystring("FName")%>" name="FName">
<%
GetConnection
Set objRS = CreateObject("ADODB.Recordset")
objRS.Open strSQL, Conn
End If
[highlight]'If there are no records, display an error
If objRS.EOF Then
Response.Write "No records match your criteria, please try again."
Else
objRS.MoveFirst
%>
[/highlight]
<form name="details">
<input type="text" value="<%=objRS("StaffNo")%>" name="StaffNo"><p>
<input type="text" value="<%=objRS("Location")%>" name="Location">
<input type="text" value="<%=objRS("ManagerNo")%>" name="ManagerNo"><p>
<select name="Course" onChange="submit()">
<%
do while not objRS.eof %>
<option value="<%=objRS("CourseKey")%>"><%=objRS("CourseKey")%>
</option>
<%
objRS.MoveNext
loop
[highlight]'after the loop move back into the recordset so we have data to output
objRS.MoveFirst[/highlight]
%>
</select>
<input type="text" value="<%=objRS("CourseDate")%>" name="CourseDate">
<input type="text" value="<%=objRS("TrainerNo")%>" name="TrainerNo">
</form>
<%
[highlight]End If[/highlight]
[highlight]End If[/highlight]
%>
<%
Dim strSQL, objRS
'--- Verify that data has been entered
If Request.QueryString("StaffNo") = "" And Request.QueryString("LName") = "" Then
ShowError "You have not entered any criteria."
End If
'--- Build the SQL based on whichever data they input
strSQL = "SELECT LName, FName, Staff.StaffNo, Location, ManagerNo, CourseKey, CourseDate, TrainerNo " & _
"FROM Staff INNER JOIN Validation WHERE Staff.StaffNo = Validation.StaffNo "
If Request.QueryString("StaffNo") <> "" Then
strSQL = strSQL & "AND Staff.StaffNo = '" & Replace(Request.QueryString("StaffNo","'","''")) & "' "
End If
If Request.QueryString("LName") <> "" Then
strSQL = strSQL & "AND Staff.LName LIKE '%" & Replace(Request.QueryString("LName","'","''")) & "'% " & _
"AND Staff.FName LIKE '%" & Replace(Request.QueryString("FName","'","''")) & "'% "
End If
'--- Get the recordset for this data
GetConnection
Set objRS = Conn.Execute(strSQL)
'--- Check for data in the recordset
If objRS.EOF Then
ShowError "Sorry, there are no records that macthed your criteria. Please Try Again."
End If
'--- Output the received data
%>
<html>
<head>
<body>
<form method="POST" action="Somewhere.asp">
<!-- Display Data in Form -->
Staff #: <input type="text" value="<%=objRS("StaffNo")%>" name="StaffNo"><br />
Name: <input type="text" value="<%=objRS("LName")%>" name="LName">,
<input type="text" value="<%=objRS("FName")%>" name="FName"><br />
Location: <input type="text" value="<%=objRS("Location")%>" name="Location"><br />
Manager #: <input type="text" value="<%=objRS("ManagerNo")%>" name="ManagerNo"><br />
Courses: <select name="Course" onChange="submit()">
<%
Do Until objRS.EOF
Response.Write "<option>" & objRS("CourseKey") & "</option>"
objRS.MoveNext
Loop
objRS.MoveFirst
%>
</select><br />
Course Date: <input type="text" value="<%=objRS("CourseDate")%>" name="CourseDate"><br />
Trainer #: <input type="text" value="<%=objRS("TrainerNo")%>" name="TrainerNo"><br />
</form>
</body>
</html>
<%
'This function clears any previous output, displays the error message and link to name1
' then forces the output to end, basically exiting early
Function ShowError(message)
response.Clear
%>
<html>
<head><META HTTP-EQUIV=Refresh CONTENT="3; URL=name1.asp"></head>
<body>
<center>
<%=message%><br />
If your browser does not redirect you to the previous page, please click <a href="name1.asp">Here</a>.
</center></body></html>
<%
Response.End
End Function
%>