Next and back problemes
I have some problems with "back" og "next" button...
I can easy use the buttons but if is use the sort in the top and after
this click "Next" then i get emty cells and "NaN"
Why ?
Her is my code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<% Option Explicit %>
<!--#include file="inc/DBConnection.asp"--><html>
<%
AabenDB
Dim oFld, SQL
'SQL = "SELECT * FROM dbo.VibroLag;"
SQL = "SELECT ItemNumber As Varenummer, ItemName As Varetekst, ItemGroup As Varegruppe, " _
& "ItemType As Varetype, CostPrice As Kostpris, SalesPrice As Salgspris FROM dbo.VibroLag"
rs.Open SQL,Connection
function aw_string(s)
s = Replace(s, "\", "\\")
s = Replace(s, """", "\""") 'replace javascript control characters - ", \
rem s = Replace(s, vbCr, "\r")
rem s = Replace(s, vbLf, "\n")
aw_string = """" & s & """"
end function
function aw_headers(rs)
Dim i, count, headers()
count = rs.fields.count
ReDim headers(count-1)
For i=0 to count-1
headers(i) = aw_string(rs(i).name)
Next
Response.write("[" & Join(headers, ", ") & "];")
end function
function aw_cells(rs)
Dim i, col_count, row_count, columns(), rows()
row_count = 0
col_count = rs.fields.count
ReDim columns(col_count-1)
Do while (Not rs.eof)
For i=0 to col_count-1
columns(i) = aw_string(rs(i))
Next
ReDim preserve rows(row_count)
rows(row_count) = vbTab & "[" & Join(columns, ", ") & "]"
row_count = row_count + 1
rs.MoveNext
Loop
response.write("[" & vbNewLine & Join(rows, "," & vbNewLine) & vbNewLine & "];" & vbNewLine)
end function
%>
<html>
<head>
<script src="runtime/lib/aw.js"></script>
<link href="runtime/styles/xp/aw.css" rel="stylesheet"></link>
<style>
.aw-grid-control {height: 494px; width: 875px; margin: 0px; border: none; font: menu;}
.aw-row-selector {text-align: center}
.aw-column-0 {width: 125px;}
.aw-column-1 {width: 315px;}
.aw-column-2 {text-align: right;}
.aw-column-3 {text-align: right;}
.aw-column-4 {text-align: right;}
.aw-column-5 {text-align: right;}
.aw-mouseover-row {background: #def;}
.aw-grid-cell {border-right: 1px solid threedlightshadow;}
.aw-grid-row {border-bottom: 1px solid threedlightshadow;}
.thumbnail{
position: relative;
z-index: 0;
}
.thumbnail:hover{
background-color: transparent;
z-index: 50;
}
.thumbnail span{
position: absolute;
background-color:#FFFFFF;
padding: 0px;
border: 1px solid #6F90A3;
visibility: hidden;
color: black;
text-decoration: none;
}
.thumbnail span table{ /*CSS for enlarged image*/
border-width: 0;
padding: 2px;
}
.thumbnail:hover span{ /*CSS for enlarged image on hover*/
visibility: visible;
top: 0;
left: -150px; /*position where enlarged image should offset horizontally */
}
</style>
</head>
<body>
<script>
// insert javascript arrays produced by ASP functions
var myHeaders = <%= aw_headers(rs) %>
var myCells = <%= aw_cells(rs) %>
// create grid control
var obj = new AW.UI.Grid;
// set grid text
obj.setHeaderText(myHeaders);
obj.setCellText(myCells);
// set number of columns/rows
obj.setColumnCount(myHeaders.length);
obj.setRowCount(myCells.length);
// enable row selectors
obj.setSelectorVisible(true);
obj.setSelectorText(function(i){return this.getRowPosition(i)+1});
// set headers width/height
obj.setSelectorWidth(30);
obj.setHeaderHeight(20);
// set row selection
obj.setSelectionMode("single-row");
// set click action handler
obj.onCellClicked = function(event, col, row){window.status = this.getCellText(col, row)};
obj.setColumnCount(6);
obj.setRowCount(25);
var button = new AW.UI.Button;
button.setControlText("<< Back");
document.write(button);
button.onControlClicked = function(){
var x = obj.getRowOffset();
if (x==0)
{
exit();
}
obj.setRowOffset(x-25);
obj.refresh();
}
var button = new AW.UI.Button;
button.setControlText("Next >>");
document.write(button);
button.onControlClicked = function(){
var x = obj.getRowOffset();
if (x==obj.setRowCount)
{
exit();
}
obj.setRowOffset(x+25);
obj.refresh();
}
// write grid to the page
document.write(obj);
</script>
<form action="senddate.asp" method="post">
<input name="Itemnumber" id="ItemNumber" type="hidden" value="<% =ItemNumber %>">
<input name="senddate" type="button" value="Send data">
</form>
</body>
</html>
<%
rs.close
Connection.close
%>
I can easy use the buttons but if is use the sort in the top and after
this click "Next" then i get emty cells and "NaN"
Why ?
Her is my code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<% Option Explicit %>
<!--#include file="inc/DBConnection.asp"--><html>
<%
AabenDB
Dim oFld, SQL
'SQL = "SELECT * FROM dbo.VibroLag;"
SQL = "SELECT ItemNumber As Varenummer, ItemName As Varetekst, ItemGroup As Varegruppe, " _
& "ItemType As Varetype, CostPrice As Kostpris, SalesPrice As Salgspris FROM dbo.VibroLag"
rs.Open SQL,Connection
function aw_string(s)
s = Replace(s, "\", "\\")
s = Replace(s, """", "\""") 'replace javascript control characters - ", \
rem s = Replace(s, vbCr, "\r")
rem s = Replace(s, vbLf, "\n")
aw_string = """" & s & """"
end function
function aw_headers(rs)
Dim i, count, headers()
count = rs.fields.count
ReDim headers(count-1)
For i=0 to count-1
headers(i) = aw_string(rs(i).name)
Next
Response.write("[" & Join(headers, ", ") & "];")
end function
function aw_cells(rs)
Dim i, col_count, row_count, columns(), rows()
row_count = 0
col_count = rs.fields.count
ReDim columns(col_count-1)
Do while (Not rs.eof)
For i=0 to col_count-1
columns(i) = aw_string(rs(i))
Next
ReDim preserve rows(row_count)
rows(row_count) = vbTab & "[" & Join(columns, ", ") & "]"
row_count = row_count + 1
rs.MoveNext
Loop
response.write("[" & vbNewLine & Join(rows, "," & vbNewLine) & vbNewLine & "];" & vbNewLine)
end function
%>
<html>
<head>
<script src="runtime/lib/aw.js"></script>
<link href="runtime/styles/xp/aw.css" rel="stylesheet"></link>
<style>
.aw-grid-control {height: 494px; width: 875px; margin: 0px; border: none; font: menu;}
.aw-row-selector {text-align: center}
.aw-column-0 {width: 125px;}
.aw-column-1 {width: 315px;}
.aw-column-2 {text-align: right;}
.aw-column-3 {text-align: right;}
.aw-column-4 {text-align: right;}
.aw-column-5 {text-align: right;}
.aw-mouseover-row {background: #def;}
.aw-grid-cell {border-right: 1px solid threedlightshadow;}
.aw-grid-row {border-bottom: 1px solid threedlightshadow;}
.thumbnail{
position: relative;
z-index: 0;
}
.thumbnail:hover{
background-color: transparent;
z-index: 50;
}
.thumbnail span{
position: absolute;
background-color:#FFFFFF;
padding: 0px;
border: 1px solid #6F90A3;
visibility: hidden;
color: black;
text-decoration: none;
}
.thumbnail span table{ /*CSS for enlarged image*/
border-width: 0;
padding: 2px;
}
.thumbnail:hover span{ /*CSS for enlarged image on hover*/
visibility: visible;
top: 0;
left: -150px; /*position where enlarged image should offset horizontally */
}
</style>
</head>
<body>
<script>
// insert javascript arrays produced by ASP functions
var myHeaders = <%= aw_headers(rs) %>
var myCells = <%= aw_cells(rs) %>
// create grid control
var obj = new AW.UI.Grid;
// set grid text
obj.setHeaderText(myHeaders);
obj.setCellText(myCells);
// set number of columns/rows
obj.setColumnCount(myHeaders.length);
obj.setRowCount(myCells.length);
// enable row selectors
obj.setSelectorVisible(true);
obj.setSelectorText(function(i){return this.getRowPosition(i)+1});
// set headers width/height
obj.setSelectorWidth(30);
obj.setHeaderHeight(20);
// set row selection
obj.setSelectionMode("single-row");
// set click action handler
obj.onCellClicked = function(event, col, row){window.status = this.getCellText(col, row)};
obj.setColumnCount(6);
obj.setRowCount(25);
var button = new AW.UI.Button;
button.setControlText("<< Back");
document.write(button);
button.onControlClicked = function(){
var x = obj.getRowOffset();
if (x==0)
{
exit();
}
obj.setRowOffset(x-25);
obj.refresh();
}
var button = new AW.UI.Button;
button.setControlText("Next >>");
document.write(button);
button.onControlClicked = function(){
var x = obj.getRowOffset();
if (x==obj.setRowCount)
{
exit();
}
obj.setRowOffset(x+25);
obj.refresh();
}
// write grid to the page
document.write(obj);
</script>
<form action="senddate.asp" method="post">
<input name="Itemnumber" id="ItemNumber" type="hidden" value="<% =ItemNumber %>">
<input name="senddate" type="button" value="Send data">
</form>
</body>
</html>
<%
rs.close
Connection.close
%>
Tengs
November 30,