File: D:/web/itpartnership/speedtest/index.asp
<%Option Explicit%>
<!--#include file="dbfunctions.asp"-->
<%DisableCache%>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252">
<meta charset="windows-1252" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Speedtest Results</title>
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<!--<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>-->
<script src="jquery/jquery-3.5.1.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js" ></script>
<!--<script type='text/javascript' src='https://s3.amazonaws.com/dynatable-docs-assets/js/jquery-1.9.1.min.js'></script>-->
<link rel="stylesheet" media="all" href="dynatable/jquery.dynatable.css" />
<script type='text/javascript' src='dynatable/jquery.dynatable.js'></script>
</head>
<body>
<%
Initialise
ShowResultsTable
Finalise
%>
</body>
</html>
<%
Sub Initialise
Dim LConnectionStr, LDriver, LServer, LDatabase, LUser, LPassword
LServer = "127.0.0.1"
LDatabase = "speedtest"
LUser = "common"
LPassword = "itpcommon123"
LConnectionStr = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=" & LServer & "; DATABASE=" & LDatabase & "; UID=" & LUser & ";PASSWORD=" & LPassword & "; OPTION=3;"
Application("ConnectionString") = LConnectionStr
OpenDatabase
End Sub
Sub Finalise
CloseDatabase
End Sub
Sub ShowResultsTable
OpenQuery("SELECT * FROM results ORDER BY ID DESC")
ShowTableHeader "R" ' should be after OpenQuery
Do While Not EndOfQuery
ShowTableRecord "R"
NextQueryRecord
Loop
ShowTableFooter "R"
End Sub
Sub ShowTableHeader(AType)
' for each field
Dim LoRS
Set LoRS = oRS ' *** oRS is a global defined in dbfunctions.asp perhaps create a function to return this, or a create a different solutions
%>
<div class="dynatable-demo">
<table id="search-example-<%=AType%>" class="table table-responsive table-sm table-bordered table-striped">
<thead>
<tr>
<%
Dim i, LFieldName, LFieldCount
LFieldCount = oRS.Fields.Count
For i = 0 To LFieldCount - 1
LFieldName = LoRS.Fields.Item(i).Name
Response.Write "<th>" & LFieldName & "</th>"
Next
%>
</tr>
</thead>
<tbody>
<%
End Sub
' (SS,14/9/20) new AType of "P" for previous orders
Sub ShowTableRecord(AType)
' for each field
Dim LoRS
Set LoRS = oRS ' *** oRS is a global defined in dbfunctions.asp perhaps create a function to return this, or a create a different solutions
%>
<tr>
<%
Dim i, LFieldName, LFieldValue, LFieldCount
LFieldCount = oRS.Fields.Count
For i = 0 To LFieldCount - 1
LFieldName = LoRS.Fields.Item(i).Name
LFieldValue = LoRS.Fields.Item(i)
Response.Write "<td>" & LFieldValue & "</td>"
Next
%>
</tr>
<%
End Sub
Sub ShowTableFooter(AType)
%>
</tbody>
</table>
</div>
<script>
(function() {
var dynatable = $('#search-example-<%=AType%>').dynatable({
features: {
paginate: <%=IIF(AType = "D", "true", "false")%>,
recordCount: <%=IIF(AType = "D", "true", "false")%>,
sorting: false,
perPageSelect: false,
search: false
},
dataset: {
perPageDefault: 100
}
}).data('dynatable');
})();
// (SS,2/5/19) following from https://techoverflow.net/2018/03/30/copying-strings-to-the-clipboard-using-pure-javascript/
function copyStringToClipboard(str) {
// Create new element
var el = document.createElement('textarea');
// Set value (string to be copied)
el.value = str;
// Set non-editable to avoid focus and move outside of view
el.setAttribute('readonly', '');
el.style = {position: 'absolute', left: '-9999px'};
document.body.appendChild(el);
// Select text inside element
el.select();
// Copy text to clipboard
document.execCommand('copy');
// Remove temporary element
document.body.removeChild(el);
}
</script>
<%
End Sub
%>