Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need your help, please

Status
Not open for further replies.

janise

Technical User
May 25, 2003
161
US
I need help with paging, please.
In the below code snippet, I need to give users the ability to click on the "Next" button to view the next record.
Then also allow them to be able to return to previous record with the "Previous" button.
The users want it in this format.
I tried to integrate everything into this code but without success.
I then wrote two additional asps, one MoveNex and one MovePrev such that once you click the "Next" or "Previous" button it calls one of the asps to perform that action.
Problem is none is working.
I have spent a week trying to make it work.
Please help me!

<TR>
<TD bgcolor=khaki COLSPAN=2 BGCOLOR=WHITE ALIGN=CENTER>

<!INPUT TYPE=SUBMIT VALUE=&quot;Update&quot;-->
<!INPUT TYPE=RESET VALUE=&quot;Reset&quot;-->

<INPUT TYPE=BUTTON VALUE=&quot;Next&quot; OnClick=&quot;location='co_applicant.asp'&quot;>
<INPUT TYPE=BUTTON VALUE=&quot;Previous&quot; OnClick=&quot;location='co_applicant.asp'&quot;>
<INPUT TYPE=BUTTON VALUE=&quot;Add Record&quot; OnClick=&quot;location='new_applicant.asp'&quot;>
<INPUT TYPE=BUTTON VALUE=&quot;Delete Record&quot; OnClick=&quot;location='del_rec.asp?ssnum=????'&quot;>
<INPUT TYPE=BUTTON VALUE=&quot;Find&quot; OnClick=&quot;location='getRecs.asp'&quot;>
<INPUT TYPE=BUTTON VALUE=&quot;Main Menu&quot; onClick=&quot;location='main_menu.asp'&quot;>

</TD>
</TR>


*******************************
This is moveNext, similar to MovePrevious
*******************************
<%@ Language=VBScript%>
<%Option Explicit%>
<%Response.buffer=true%>

Dim RecSet As Object 'Recordset

<%

RecSet.MoveNext 'Move to next record
Response.Redirect &quot;view_recs.asp&quot;

%>


Thanks in advance
 
thanks GaryC123!
I am not sorting it yet!
I jus want the moveNex or movePrev to work.
Do I need to sort it before it works?
If so, I can sort it by ID and Id is numeric.
 
If its just a simple case of sort by index and nothing else and without going into anything more complicated then
on the page you display the record create an hidden field containing the present index retrieved from the database (this would go after the select statement).
On the Next (and Previous page) retrieve the index value from the hidden field and place this in the the select statement either -1 or +1

Hidden field something like this
<input type=&quot;hidden&quot; name=&quot;index&quot; value=&quot;<%=rs(&quot;id&quot;)%>&quot;>

select statement something like this
nextindex=request(&quot;index&quot;)+1 (or -1 on the previous page)
&quot;select * from db where id= '&quot; & nextindex &quot;'&quot;
and another hidden field
<input type=&quot;hidden&quot; name=&quot;index&quot; value=&quot;<%=rs(&quot;id&quot;)%>&quot;>
 
oops like this

&quot;select * from db where id= '%&quot; & nextindex & &quot;%'&quot;
 
here is the entire code!
can you please modify.
Sorry to dump on you, this is killing me.

<%@ Language=VBScript%>

<%Response.buffer=true%>

<% Response.Expires = 0%>

<%
Set connectionToDatabase=Server.CreateObject(&quot;ADODB.Connection&quot;)
Set rs=Server.CreateObject(&quot;ADODB.Recordset&quot;)
connectionToDatabase.Open &quot;DSN=sTract;UID=sokeh;PWD=sonn1e&quot;


rs.Open &quot;Select * from Driver where DriverID=&quot; & &quot;'&quot; & Request.QueryString(&quot;SS_NUM&quot;) & &quot;'&quot; & &quot; OR LName=&quot; & &quot;'&quot; & Request.QueryString(&quot;Lname&quot;) & &quot;'&quot;,connectionToDatabase,1


%>


<HEAD>
<LINK REL=STYLESHEET TYPE=&quot;text/css&quot; HREF=&quot;af_styles.css&quot;>

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!-- hide from non-JavaScript browsers

//make and initialize array
function MakeArray(size)
{
this.length = size;

for(i = 1; i <= size; i++)
this = null;

return this;
}

//create a PizzaTypes object with two attributes
function PizzaType(strName, iCost)
{
this.name = strName;
this.cost = iCost;
}

function ProgramType(progName, progID)
{
this.name = progName;
this.id = progID;
}


programList = new MakeArray(6);
programList[1] = new ProgramType(&quot;MCSE & Networking&quot;, &quot;MCSE&quot;);
programList[2] = new ProgramType(&quot;Internet WebMaster(CIW)&quot;, &quot;CIW&quot;);
programList[3] = new ProgramType(&quot;MCDBA&quot;, &quot;MCDBA&quot;);
programList[4] = new ProgramType(&quot;Cisco Systems&quot;, &quot;CISCO&quot;);
programList[5] = new ProgramType(&quot;A+&quot;, &quot;APLUS&quot;);
programList[6] = new ProgramType(&quot;Other&quot;, &quot;OTHER&quot;);




referrerList = new MakeArray(6);
referrerList[1] = new ProgramType(&quot;Friend&quot;, &quot;FR&quot;);
referrerList[2] = new ProgramType(&quot;TV&quot;, &quot;TV&quot;);
referrerList[3] = new ProgramType(&quot;Radio&quot;, &quot;RA&quot;);
referrerList[4] = new ProgramType(&quot;News Paper&quot;, &quot;NP&quot;);
referrerList[5] = new ProgramType(&quot;Internet&quot;, &quot;F&quot;);
referrerList[6] = new ProgramType(&quot;Other&quot;, &quot;OT&quot;);



function createSelect(strName, objList)
{
var tStr = &quot;<SELECT NAME=\&quot;&quot; + strName + &quot;\&quot; >&quot;
+ &quot;<OPTION SELECTED>---Select one---&quot;;

for(var i=1; i<=objList.length; i++)
tStr += &quot;<OPTION>&quot; + objList.name;

tStr += &quot;</SELECT>&quot;;

return tStr;
}


function createRadio(strName, objList)
{
var tStr = &quot;&quot;;

for(var i=1; i<=objList.length; i++)
{
tStr += &quot;<BR><INPUT NAME=\&quot;&quot; + strName + &quot;\&quot; &quot;
+ &quot;TYPE=checkBox VALUE=\&quot;&quot; + objList.name + &quot;\&quot;>&quot;
+ &quot;<FONT CLASS='Arial10'>&quot; + objList.name;
}

return tStr;
}


// end hide -->
</SCRIPT>


<script language=&quot;JavaScript&quot;>
function verify(doco)
{
var msg = &quot;&quot;;
var intSelCount = 0;

//loop though all of form variables
for (var i=0; i < doco.form.length; i++){
var e = doco.form.elements;

if (e.name == &quot;lid&quot;)
{
for (var s=0; s < e.length; s++)
{
if (e.options.selected == true)
{
intSelCount++;
}
}
}

if (e.name == &quot;PAYMT_OPTION&quot;)
{
for (var s=0; s < e.length; s++)
{
if (e.options.selected == true)
{
intSelCount++;
}
}
}
}

if (intSelCount > 10)
{
msg = &quot;Please limit your selection.&quot;;
alert(msg);
return false;
}

doco.form.submit();
return true;
}
</script>


</HEAD>


<CENTER>
<BODY BGCOLOR=&quot;steelBLUE&quot;>
<TABLE>
<tr>
<td>
<img src=&quot;images/pworks.jpg&quot;>
</td>
</tr>
<TR>
<TD>
<font class=&quot;ArialNarrow12&quot; COLOR=&quot;WHITE&quot;><b>AccidenttTrac - New Driver Screen</b></font>
    

</TD>
</TR>
</TABLE>

<FORM ACTION=&quot;insertRec.asp&quot; METHOD=&quot;POST&quot;>
<TABLE WIDTH=98% BORDER=0 BGCOLOR=&quot;SILVER&quot; CELLPADDING=4 CELLSPACING=0 >
<TR>
<TD ALIGN=CENTER VALIGN=TOP>
<TABLE>
<TD ALIGN=LEFT> <FONT CLASS='Arial10' COLOR=RED><B>
Driver SS#
</TD>
<TD ALIGN=LEFT>
<INPUT TYPE=&quot;TEXT&quot; NAME=&quot;SS_NUM&quot; VALUE=&quot;&quot; >
</TD>
</TR>


<TR>
<TD ALIGN=LEFT> <B><FONT CLASS='Arial10'>
First Name<B>
</TD>
<TD ALIGN=LEFT>
<INPUT TYPE=&quot;TEXT&quot; NAME=&quot;FIRST_NAME&quot; VALUE=&quot;&quot; >
</TD>
</TR>

<TR>
<TD ALIGN=LEFT> <B><FONT CLASS='Arial10'>
Last Name<B>
</TD>
<TD ALIGN=LEFT>
<INPUT TYPE=&quot;TEXT&quot; NAME=&quot;LAST_NAME&quot; VALUE=&quot;&quot; >
</TD>
</TR>

<TR>
<TD><FONT CLASS='Arial10' ><B>
Middle Initial
</TD>
<TD>
<INPUT TYPE=&quot;TEXT&quot; NAME=&quot;Middle_Initial&quot; VALUE=&quot;&quot; >
</TD>
</TR>

<TR>
<TD><FONT CLASS='Arial10' ><B>
Driver's Gender
</TD>
<TD>
<INPUT TYPE=&quot;TEXT&quot; NAME=&quot;Driver_Sex&quot; VALUE=&quot;&quot; >
</TD>
</TR>

<TR>
<TD><FONT CLASS='Arial10' ><B>
First Street Address
</TD>
<TD>
<INPUT TYPE=&quot;TEXT&quot; NAME=&quot;ADDRESS1&quot; VALUE=&quot;&quot; >
</TD>
</TR>

<TR>
<TD><FONT CLASS='Arial10' ><B>
Second Street Address
</TD>
<TD>
<INPUT TYPE=&quot;TEXT&quot; NAME=&quot;ADDRESS2&quot; VALUE=&quot;&quot; >
</TD>
</TR>

<TR>
<TD><FONT CLASS='Arial10' ><B>
City
</TD>
<TD>
<INPUT TYPE=&quot;TEXT&quot; NAME=&quot;CITY&quot; VALUE=&quot;&quot; >
</TD>
</TR>

<TR>
<TD><FONT CLASS='Arial10' ><B>
State
</TD>
<TD>
<INPUT TYPE=&quot;TEXT&quot; NAME=&quot;STATE&quot; VALUE=&quot;&quot; >
</TD>
</TR>


<TR>
<TD><FONT CLASS='Arial10' ><B>
Zip Code
</TD>
<TD>
<INPUT TYPE=&quot;TEXT&quot; NAME=&quot;ZIP_CODE&quot; VALUE=&quot;&quot; >
</TD>
</TR>


<TR>
<TD><FONT CLASS='Arial10' ><B>
Home Phone
</TD>
<TD>
<INPUT TYPE=&quot;TEXT&quot; NAME=&quot;HOME_PHONE&quot; VALUE=&quot;&quot; >
</TD>
</TR>

<TR>
<TD><FONT CLASS='Arial10' ><B>
Work/Cell
</TD>
<TD>
<INPUT TYPE=&quot;TEXT&quot; NAME=&quot;Work_PHONE&quot; VALUE=&quot;&quot; >
</TD>
</TR>


<TR>
<TD><FONT CLASS='Arial10' ><B>
Email
</TD>
<TD>
<INPUT TYPE=&quot;TEXT&quot; NAME=&quot;EMAIL_Address&quot; VALUE=&quot;&quot; >

</TD>
</TR>

<TR>
<TD><FONT CLASS='Arial10' ><B>
Is Our Driver at Fault?
</TD>
<TD>
<INPUT TYPE=&quot;TEXT&quot; NAME=&quot;Fault&quot; VALUE=&quot;&quot; >
</TD>
</TR>
<TR>
<TD><FONT CLASS='Arial10' ><B>
Driving Under What Influence?
</TD>
<TD>
<INPUT TYPE=&quot;TEXT&quot; NAME=&quot;Influence_Type&quot; VALUE=&quot;&quot; >
</TD>
</TR>
<TR>
<TD><FONT CLASS='Arial10' ><B>
What Type Of Injury?
</TD>
<TD>
<INPUT TYPE=&quot;TEXT&quot; NAME=&quot;Injury_Type&quot; VALUE=&quot;&quot; >
</TD>
</TR>

</TABLE>
</TD>

<TD VALIGN=&quot;CENTER&quot; ALIGN=CENTER >

<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=4 BORDERCOLOR=&quot;YELLOW&quot; >
<TR>
<TD align=left>
<FONT CLASS='Arial10' COLOR='darkred'><B>
Source of referral?</B>
</TD>
<TD>

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!-- begin hide
document.write(createSelect(&quot;Referrer&quot;, referrerList) + &quot;<BR>&quot;);

// end hide -->
</SCRIPT>

</TD>
</TR>

<TR>
<TD><FONT CLASS='Arial10' COLOR='darkred'><B>
Years in IT</B>
</TD>
<TD>
<SELECT NAME='IT_YRS' SIZE=1>
<OPTION VALUE='' SELECTED>---Select one---
<OPTION VALUE='none'>none
<OPTION VALUE='1 - 2'>1 - 2
<OPTION VALUE='over 2'>over 2
<OPTION VALUE='Other'>Other
</SELECT>

</TD>
</TR>

<TR>
<TD><FONT CLASS='Arial10' COLOR='darkred'><B>
How many times in accident</B>
</TD>
<TD>
<SELECT NAME='NoOfAccidents' SIZE=1>
<OPTION VALUE='' SELECTED>---Select one---
<OPTION VALUE='none'>none
<OPTION VALUE='1'>1
<OPTION VALUE='2'>2
<OPTION VALUE='3'>3
<OPTION VALUE='4'>4
<OPTION VALUE='5'>5
<OPTION VALUE='over 5'>Over 5
</SELECT>

</TD>
</TR>


<TR COLSPAN=2>
<TD><FONT CLASS='Arial10' COLOR='darkred'><B>
Current annual salary </B>
</TD>
<TD>
<SELECT NAME='CURR_SAL' SIZE=1>
<OPTION VALUE='none' SELECTED>---Select one---
<OPTION VALUE='under 20,000'>under 20,000
<OPTION VALUE='20,000 - 30,000'>20,000 - 30,000
<OPTION VALUE='31,000 - 40,000'>31,000 - 40,000
<OPTION VALUE='Over 45,000'>Over 45,000
</SELECT>
</TD>
</TR>

<TR COLSPAN=2>
<TD><FONT CLASS='Arial10' COLOR='darkred'><B>
Educational Level </B>
</TD>
<TD>
<SELECT NAME='EDU_LEVEL' SIZE=1>
<OPTION VALUE='-1' SELECTED>---Select one---
<OPTION VALUE='High School'>High School
<OPTION VALUE='College'>College
<OPTION VALUE='Post Graduate'>Post Graduate
<OPTION VALUE='Other'>Other
</SELECT>
</TD>
</TR>

<TR>
<TD ><FONT CLASS='Arial10' COLOR='darkred'>
<B>Payment Option </B>
</TD>
<TD>
<SELECT NAME='PAYMT_OPTION' MULTIPLE SIZE=3>
<OPTION VALUE='-1' SELECTED>---Select one---
<OPTION VALUE='Check'>Check
<OPTION VALUE='Credit Card'>Credit Card
<OPTION VALUE='Loan'>Loan
<OPTION VALUE='Cash'>Cash
<OPTION VALUE='Other'>Other
</SELECT>
</TD>
</TR>


<TR>
<TD>

<FONT CLASS='Arial10' COLOR='darkred'><B>
Intended Program of study? </B></FONT>

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!-- begin hide
document.write(createRadio(&quot;programs&quot;, programList) + &quot;<BR>&quot;);
// end hide -->
</SCRIPT>

<FONT CLASS='Arial10' COLOR='darkred'>
<B>Co-Applicant? </B></FONT>
<INPUT NAME=&quot;CoApp&quot; TYPE=radio VALUE=&quot;Yes&quot;>Yes  
<INPUT NAME=&quot;CoApp&quot; TYPE=radio VALUE=&quot;No&quot;>No
</TD>
<TD VALIGN=TOP>
<FONT CLASS='Arial10' COLOR='darkred'>
<B>Own PC? </B></FONT>
<INPUT NAME=&quot;ownpc&quot; TYPE=radio VALUE=&quot;Yes&quot;>Yes  
<INPUT NAME=&quot;ownpc&quot; TYPE=radio VALUE=&quot;No&quot;>No
<HR NOSHADE>

<FONT CLASS='Arial10' COLOR='darkred'>
<B>Reason For Selecting OTS </B></FONT><BR>
<TEXTAREA VALUE=&quot;&quot; NAME=&quot;reason&quot; rows=4 cols=25></TextArea>



</TD>
</TR>
</TABLE>

</TD>
</TR>

<tr>
<td colspan=2 >
<table border=5 width=100%>
<tr>
<td ALIGN=CENTER>

<table border = 1 BORDERCOLOR=RED CELLSPACING=0 CELLPADDING=2>
<TR>
<TD><FONT CLASS='Arial10' ><B>
Contact Date
</TD>
<TD>
<%
Response.Write(&quot;<INPUT TYPE=TEXT NAME='contact_dt' VALUE=&quot; & date() & &quot; >&quot;)
%>
</TD>
</TR>

<TR>
<TD><FONT CLASS='Arial10' ><B>
Class
</TD>
<TD>
<INPUT TYPE=TEXT NAME='class' VALUE=&quot;&quot; >
</TD>
</TR>

<TR>
<TD><FONT CLASS='Arial10' ><B>
Amount Paid
</TD>
<TD>
<INPUT TYPE=TEXT NAME='amount' VALUE=&quot;&quot; >
</TD>
</TR>

<TR>
<TD><FONT CLASS='Arial10' ><B>
TPR
</TD>
<TD>
<INPUT TYPE=TEXT NAME='tpr' VALUE=&quot;&quot; >
</TD>
</TR>

<TR>
<TD><FONT CLASS='Arial10' ><B>
Accounts Recievable
</TD>
<TD>
<INPUT TYPE=TEXT NAME='accts_recv' VALUE=&quot;&quot;>
</TD>
</TR>
</table>
</td>

<td VALIGN=TOP >
<table border = 0>
<TR>
<TD>
<FONT CLASS='Arial10' ><B>
Comments/Notes</b></FONT><br>

<TEXTAREA rows=4 cols=30> </textarea>
</TD>
</TR>
</table>

</td>
</tr>
</table>

</td>
</tr>

<TR>
<TD bgcolor=khaki COLSPAN=2 BGCOLOR=WHITE ALIGN=CENTER>

<!INPUT TYPE=SUBMIT VALUE=&quot;Update&quot;-->
<!INPUT TYPE=RESET VALUE=&quot;Reset&quot;-->

<INPUT TYPE=BUTTON VALUE=&quot;Next&quot; OnClick=&quot;location='co_applicant.asp'&quot;>
<INPUT TYPE=BUTTON VALUE=&quot;Previous&quot; OnClick=&quot;location='co_applicant.asp'&quot;>
<INPUT TYPE=BUTTON VALUE=&quot;Add Record&quot; OnClick=&quot;location='new_applicant.asp'&quot;>
<INPUT TYPE=BUTTON VALUE=&quot;Delete Record&quot; OnClick=&quot;location='del_rec.asp?ssnum=????'&quot;>
<INPUT TYPE=BUTTON VALUE=&quot;Find&quot; OnClick=&quot;location='getRecs.asp'&quot;>
<INPUT TYPE=BUTTON VALUE=&quot;Main Menu&quot; onClick=&quot;location='main_menu.asp'&quot;>

</TD>
</TR>



</TABLE>
</FORM>
</CENTER>

</BODY>

 
This at the beginning

<%Response.buffer=true
Response.Expires = 0
on error resume next
Set connectionToDatabase=Server.CreateObject(&quot;ADODB.Connection&quot;)
Set rs=Server.CreateObject(&quot;ADODB.Recordset&quot;)
connectionToDatabase.Open &quot;DSN=sTract;UID=sokeh;PWD=sonn1e&quot;
if request(&quot;value&quot;)=&quot;next&quot; then
tempid=request(&quot;index&quot;)+1
elseif request(&quot;value&quot;)=&quot;previous&quot; then
tempid=request(&quot;index&quot;)-1
else
tempid=request(&quot;SS_NUM&quot;)
end if
rs.Open &quot;Select * from Driver where DriverID=&quot; & &quot;'&quot; & tempid & &quot;'&quot; & &quot; OR LName=&quot; & &quot;'&quot; & Request.QueryString(&quot;Lname&quot;) & &quot;'&quot;,connectionToDatabase,1
tempid=rs(&quot;DriverID&quot;)
%>

and your button values to this

<INPUT TYPE=BUTTON VALUE=&quot;Next&quot; OnClick=&quot;location=thispagename.asp?value=next&index=<%=tempid%>'&quot;>
<INPUT TYPE=BUTTON VALUE=&quot;Previous&quot; OnClick=&quot;location=thispagename.asp?value=previous&index=<%=tempid%>'&quot;>
<INPUT TYPE=BUTTON VALUE=&quot;Add Record&quot; OnClick=&quot;location='new_applicant.asp'&quot;>
<INPUT TYPE=BUTTON VALUE=&quot;Delete Record&quot; OnClick=&quot;location='del_rec.asp?ssnum=????'&quot;>
<INPUT TYPE=BUTTON VALUE=&quot;Find&quot; OnClick=&quot;location='getRecs.asp'&quot;>
<INPUT TYPE=BUTTON VALUE=&quot;Main Menu&quot; onClick=&quot;location='main_menu.asp'&quot;>


should do it I think
 
I deleted the apostrophe from the start of thispagename by mistake!
 
GaryC123,
thank you so very much.
Just to be sure one thing.
1, the thispagename applies to the name of this asp.
In this case, the name of this asp page is view_Res.asp.
I know these questions are dumb and I am sorry.
I have struggled with this I just want to get it right now I got help from a good individual like you.
I am leaving this place now.
I will post result of this help on Monday.
Again, thanks a bunch!!
 
Yep thats right, change thispagename to view_Res.asp :eek:) <p><b><font face=&quot;Arial&quot; size=&quot;2&quot;>
<span style=&quot;FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-FAMILY: Arial&quot;>
Saturday...... &nbsp; 12:00hrs.....</span></font></b><img src=&quot; height=&quot;50&quot; src=&quot; wi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top