have a question
how to i move through records with buttons....i tried several ways but none of them works.
here is the code i wrote so far for one of the documents.
if i click on a button nothing happens
<%@LANGUAGE="VBScript"%>
<!-- #INCLUDE VIRTUAL="adovbs.inc" -->
<html>
<head>
<title>products</title>
<body bgcolor="#FFFFFF" text="#000000">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<%
dim SQLQuery
If Not IsEmpty(Request.Form("MoveAction") Then
strAction = Request.Form("MoveAction"
varPosition = Request.Form("Position"
set myConnection = Server.CreateObject("ADODB.Connection"
myConnection.Open "DSN=ph;UID=sa"
set rec = Server.CreateObject("ADODB.Recordset"
rec.ActiveConnection = myConnection
rec.CursorType = adOpenDynamic
rec.CursorLocation = adUseClient
rec.LockType = adLockOptimistic
SQLQuery = "select prod_id,descr from prod"
rec.Open SQLQuery, myConnection
rec.MoveFirst
rec.AbsolutePosition = varPosition
Select Case strAction
Case "MoveNext"
rec.MoveNext
If rec.EOF Then
rec.MoveLast
strMessage = "Can't move beyond the last record."
End If
Case "MovePrev"
rec.MovePrevious
If rec.BOF Then
rec.MoveFirst
strMessage = "Can't move beyond the first record."
End If
Case "MoveLast"
rec.MoveLast
Case "MoveFirst"
rec.MoveFirst
End Select
End If
%>
<form method="post" action="prod.asp">
<table width="35%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>prod_id</td>
<td>
<input type="text" name="prodtext" value="<%=rec.fields(0)%>" maxlength="500" size="100">
</td>
</tr>
<tr>
<td>descr[iption]</td>
<td>
<input type="text" name="descrtext" value="<%=rec.fields(1)%>" size="100" maxlength="500">
</td>
</tr>
</table>
<table width="14%" border="0" cellspacing="0" cellpadding="0" height="52">
<tr>
<td width="9%">
<input type=Button name="cmLast" value="<<">
</td>
<td width="10%">
<input type=Button name="cmdPrev" value="<">
</td>
<td width="11%">
<input type=Button name="cmdNext" value=">">
</td>
<td width="70%">
<input type=Button name="cmdFirst" value=">>">
</td>
</tr>
<tr>
<td width="9%"> </td>
<td width="10%"> </td>
<td width="11%"> </td>
<td width="70%"> </td>
</tr>
</table>
<p> </p>
</form>
<p> </p>
<Form Method=Post
Action="<%=Request.ServerVariables("SCRIPT_NAME"%>"
Name="form_a">
<Input Type="Hidden" Size="4" Name="MoveAction" Value="Move">
<Input Type="Hidden" Size="4" Name="Position" Value="<%= rec.AbsolutePosition %>">
</Form>
</body>
<script language="VBScript">
Sub cmdPrev_OnClick
rec.MovePrevious
Document.Form.MoveAction.Value = "MovePrev"
Document.Form.Submit
End Sub
Sub cmdNext_OnClick
rec.MoveNext
Document.form.MoveAction.Value = "MoveNext"
Document.Form.Submit
End Sub
Sub cmdFirst_OnClick
rec.MoveFirst
Document.form.MoveAction.Value = "MoveFirst"
Document.Form.Submit
End Sub
Sub cmdLast_OnClick
rec.MoveLast
Document.form.MoveAction.Value = "MoveLast"
Document.Form.Submit
End Sub
</script>
<html>
dont have no idea and nobody to ask for here were im working so....
caz [sig][/sig]
how to i move through records with buttons....i tried several ways but none of them works.
here is the code i wrote so far for one of the documents.
if i click on a button nothing happens
<%@LANGUAGE="VBScript"%>
<!-- #INCLUDE VIRTUAL="adovbs.inc" -->
<html>
<head>
<title>products</title>
<body bgcolor="#FFFFFF" text="#000000">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<%
dim SQLQuery
If Not IsEmpty(Request.Form("MoveAction") Then
strAction = Request.Form("MoveAction"
varPosition = Request.Form("Position"
set myConnection = Server.CreateObject("ADODB.Connection"
myConnection.Open "DSN=ph;UID=sa"
set rec = Server.CreateObject("ADODB.Recordset"
rec.ActiveConnection = myConnection
rec.CursorType = adOpenDynamic
rec.CursorLocation = adUseClient
rec.LockType = adLockOptimistic
SQLQuery = "select prod_id,descr from prod"
rec.Open SQLQuery, myConnection
rec.MoveFirst
rec.AbsolutePosition = varPosition
Select Case strAction
Case "MoveNext"
rec.MoveNext
If rec.EOF Then
rec.MoveLast
strMessage = "Can't move beyond the last record."
End If
Case "MovePrev"
rec.MovePrevious
If rec.BOF Then
rec.MoveFirst
strMessage = "Can't move beyond the first record."
End If
Case "MoveLast"
rec.MoveLast
Case "MoveFirst"
rec.MoveFirst
End Select
End If
%>
<form method="post" action="prod.asp">
<table width="35%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>prod_id</td>
<td>
<input type="text" name="prodtext" value="<%=rec.fields(0)%>" maxlength="500" size="100">
</td>
</tr>
<tr>
<td>descr[iption]</td>
<td>
<input type="text" name="descrtext" value="<%=rec.fields(1)%>" size="100" maxlength="500">
</td>
</tr>
</table>
<table width="14%" border="0" cellspacing="0" cellpadding="0" height="52">
<tr>
<td width="9%">
<input type=Button name="cmLast" value="<<">
</td>
<td width="10%">
<input type=Button name="cmdPrev" value="<">
</td>
<td width="11%">
<input type=Button name="cmdNext" value=">">
</td>
<td width="70%">
<input type=Button name="cmdFirst" value=">>">
</td>
</tr>
<tr>
<td width="9%"> </td>
<td width="10%"> </td>
<td width="11%"> </td>
<td width="70%"> </td>
</tr>
</table>
<p> </p>
</form>
<p> </p>
<Form Method=Post
Action="<%=Request.ServerVariables("SCRIPT_NAME"%>"
Name="form_a">
<Input Type="Hidden" Size="4" Name="MoveAction" Value="Move">
<Input Type="Hidden" Size="4" Name="Position" Value="<%= rec.AbsolutePosition %>">
</Form>
</body>
<script language="VBScript">
Sub cmdPrev_OnClick
rec.MovePrevious
Document.Form.MoveAction.Value = "MovePrev"
Document.Form.Submit
End Sub
Sub cmdNext_OnClick
rec.MoveNext
Document.form.MoveAction.Value = "MoveNext"
Document.Form.Submit
End Sub
Sub cmdFirst_OnClick
rec.MoveFirst
Document.form.MoveAction.Value = "MoveFirst"
Document.Form.Submit
End Sub
Sub cmdLast_OnClick
rec.MoveLast
Document.form.MoveAction.Value = "MoveLast"
Document.Form.Submit
End Sub
</script>
<html>
dont have no idea and nobody to ask for here were im working so....
caz [sig][/sig]