Hello,

Can anyone help me in this,
What i'm trying to do is that i try to break my page in case if i have too much record. But what happen is when i click on 'next' the record doesn't shows because the date that i select had been cleared after i click next so no record will show. So how can i keep the date value to stay in place all the time so the record will show no matter i clikc next or back

here is my code

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css"> 
#non-print{

    }
@media print 
{ 
#non-print{ display: none; } 

} 
</style>  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" href="jquery-ui-1.8.23.custom/css/south-street/jquery-ui-1.8.23.custom.css" rel="stylesheet" />
        <script type="text/javascript" src="jquery-ui-1.8.23.custom/js/jquery-1.8.0.min.js"></script>
        <script type="text/javascript" src="jquery-ui-1.8.23.custom/js/jquery-ui-1.8.23.custom.min.js"></script>
<script language="vbscript">
Function Submit_onclick()
document.form1.submit();
End Function
</script>
<script  type="text/javascript">
function printpr()
{
var OLECMDID = 7;
/* OLECMDID values:
* 6 - print
* 7 - print preview
* 1 - open window
* 4 - Save As
*/
var PROMPT = 1; // 2 DONTPROMPTUSER
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
WebBrowser1.ExecWB(OLECMDID, PROMPT);
WebBrowser1.outerHTML = "";
}

</script>
<title>Untitled Document</title>

</head>

<body>

<P align="Center">
<img src="image\images.jpg" width="209" height="108" />
<FONT face="Tahoma" size=6 color="Blue">
<br  />
<P align="center"><b>Daily Totalizer Report </b></P></FONT>
</P>\<table width = "300" align = center>
<Tr> 
<th align="left"> <FONT face="Tahoma" size=3 color="Blue">
<b>Product : Liquid Carbon Dioxide</b>
</FONT>
</th>
</Tr>
<tr>
<th align="left">
<FONT face="Tahoma" size=3 color="Blue">
<b>Plant &nbsp;&nbsp;&nbsp;&nbsp;:   LCO2 @ TOCGC </b>
</FONT>
</Tr>
</table>
<br />

<table align="center">
<tr><td>
<div id="non-print">
<FORM NAME = "form1" ACTION = "" method="post">
<TABLE width = "780" align = left>
<tr>
<td>
<meta charset="utf-8">

    <script>
    $(function() {
        $( "#datepicker" ).datepicker({
            dateFormat:'dd-mm-yy'
            });
    });
    </script>  


<p><b>From:</b> <input type="text" name = "Date1" id="datepicker" size="30" value=""/></p>

</td>
<td>
<meta charset="utf-8">

    <script>
    $(function() {
        $( "#datepicker" ).datepicker({
            dateFormat:'dd-mm-yy'
            });
    });
        $(function() {
        $( "#datepicker2" ).datepicker({
            dateFormat:'dd-mm-yy'
            });
    });
    </script>



<p><b>To: </b>
  <input type="text" name = "Date2" id="datepicker2" size="30"/>
  <INPUT TYPE = "SUBMIT" NAME = "Submit" Value = "Submit" > 
  <%
Dim string_var,string_part,test1
string_var= Request.ServerVariables("HTTP_USER_AGENT")
string_part= "MSIE" 
test1 =  InStr(string_var,string_part)

IF test1<>0 THEN
%>

<INPUT TYPE = "Button" NAME = "Print" Value = "Print"  onclick="JavaScript:this.style.display='none';printpr();">
<%
ELSE
%>

<INPUT TYPE = "Button" NAME = "Print"   Value = "Print"  onclick="JavaScript:window.print();">
<%

END IF %></p>






</td>
</tr>

<TR>


</TR>
</TABLE>
</FORM>
</div>
</td></tr><tr><td>
<%IF (Request.Form("Date1")  <> "")and(Request.Form("Date2")  <> "") Then
%>
<TABLE width = "780" align = left>  
<tr>
<td width="317">
<meta charset="utf-8">

    <script>
    $(function() {
        $( "#datepicker" ).datepicker({
            dateFormat:'dd-mm-yy'
            });
    });
    </script>  


<p><b>Date Start from:</b> &nbsp; &nbsp; <%Response.Write Request.Form("Date1")%></p>
</td>
<td width="451">
<meta charset="utf-8">
    <script>
    $(function() {
        $( "#datepicker" ).datepicker({
            dateFormat:'dd-mm-yy'
            });
    });
        $(function() {
        $( "#datepicker2" ).datepicker({
            dateFormat:'dd-mm-yy'
            });
    });
    </script>
<p><b>To: </b> &nbsp; &nbsp;  <%Response.Write Request.Form("Date2")%> 
</p>
</td>
</tr>
<TR>
<td style="color:#F00">Remark :  ตัดรอบทุกเที่ยงคืน</td>
</TR>
</TABLE>
</td></tr></table>
<br />
<%
Dim SplitDate1,SplitDate2,VarDate1,strVarDate1,strVarDate2
strVarDate1 = split(Request.Form("Date1"),"-")
SplitDate1 = (strVarDate1("2"))&"-"&(strVarDate1("1"))&"-"&(strVarDate1("0"))
strVarDate2 = split(Request.Form("Date2"),"-")
SplitDate2 = (strVarDate2("2"))&"-"&(strVarDate2("1"))&"-"&(strVarDate2("0"))
Dim Conn,strSQL,objRec,MyConnection
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "AutoLoad","sa","password"
strSQL = "SELECT  * FROM LCO2_DayTOT where Date between '"&SplitDate1&"' and '"&SplitDate2&"' "
Set objRec = Server.CreateObject("ADODB.Recordset")
objRec.Open strSQL, Conn, 1,3 

'**** Paging/Pagination Calculator ***'
    Dim PageLen,PageNo,TotalRecord,TotalPage,intID
    Dim PageStart,PageEnd
    PageLen = 2 
    PageNo = Request.QueryString("Page")
    if PageNo = "" Then PageNo = 1
    TotalRecord = UBound(objRec.GetRows,2)+1
    PageStart = ((PageLen*PageNo)-PageLen)
    PageEnd = PageLen
    If TotalRecord <= PageLen Then
        TotalPage =1
    ElseIf (TotalRecord Mod PageLen = 0) Then
        TotalPage =(TotalRecord/PageLen)
    Else
        TotalPage =(TotalRecord/PageLen)+1
        TotalPage = Cint(TotalPage)
    End If

%>
<TABLE border="1" align="center" width="700" BORDERCOLOR=Green>
<tr>
    <th width="15%" bgcolor="#A9F5A9" >Date</th>
    <th width="20%" bgcolor="#A9F5A9">Bay 1(KK.)</th>
    <th width="20%" bgcolor="#A9F5A9">Bay 2(KK.)</th>
    <th width="20%" bgcolor="#A9F5A9">Total(KK.) </th>
</tr>
<%

     While Not objRec.EOF 
%>
<tr>
    <th width="15%" ><%=objRec.Fields("Date").Value %></th>
    <th width="20%" ><%=objRec.Fields("Bay1_DayTOT").Value %></th>
    <th width="20%" ><%=objRec.Fields("Bay2_DayTOT").Value %></th>
    <th width="20%" ><%=objRec.Fields("Total").Value %></th>
</tr>
<%

    objRec.MoveNext
    wend
%>
</table>
</table>
Total : <%=TotalRecord%>  Page <%=PageNo%> All Page <%=TotalPage%>
    <% IF Cint(PageNo) > 1 then %>
    <a href="<%Request.ServerVariables("SCRIPT_NAME")%>?Page=1"><< First</a> 
    <a href="<%Request.ServerVariables("SCRIPT_NAME")%>?Page=<%=PageNo-1%>">< Back</a>
    <% End IF%>
    <% IF Cint(PageNo) < TotalPage Then %>
    <a href="<%Request.ServerVariables("SCRIPT_NAME")%>?Page=<%=PageNo+1%>">Next ></a> 
    <a href="<%Request.ServerVariables("SCRIPT_NAME")%>?Page=<%=TotalPage%>">Last >></a>
    <% End IF%>
    <br>
    Go to
    <% For intID = 1 To TotalPage%>
    <% if intID = Cint(PageNo) Then%>
    <b><%=intID%></b>
    <%Else%>
    <a href="<%Request.ServerVariables("SCRIPT_NAME")%>?Page=<%=intID%>"><%=intID%></a>
    <%End IF%>
    <%Next%>

<%
End IF


%>

</body>
</html>

Any comment apreciated.
Thanks.

Recommended Answers

All 5 Replies

after submit form you need to save the both datas in a session or querytring, so you can put in sql the variables. if form was submitted that variables are from form, if not then are from querystring you create or session..

Thank aninosilva for your reply i appreciate that.

I'm just a beginner so can you show a bit example of how can i achieve that using querystring or seesion that you mention above.

Thank you.

ok, an example with session

on line 70 you put like this: <FORM NAME = "form1" ACTION = "?submit=yes" method="post">
to know if form was submitted

then on lines 190 to 192 change to this

if (Request.Querystring("submit")="yes") then
strVarDate1 = split(Request.Form("Date1"),"-")
session("date1")=strVarDate1
strVarDate2 = split(Request.Form("Date2"),"-")
session("date2")=strVarDate2
else
strVarDate1=session("date1")
strVarDate2=session("date2")
end if

SplitDate1 = (strVarDate1("2"))&"-"&(strVarDate1("1"))&"-"&(strVarDate1("0"))

so now you when you submit you save dates on sessions, and in case it's not a submit the variables go to get dates from sessions

Thanks ainosilva :)

you're welcome!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.