Web Analytics Made Easy -
StatCounter Next / Previous Buttons help - CodingForum

Announcement

Collapse
No announcement yet.

Next / Previous Buttons help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Next / Previous Buttons help

    Hi

    Im extremly new to asp and web development. Ive created a basic online phone book for our intranet which works lovely talking an sql database. only thing is i cant get next and previous buttons to work. I think its because it forgets the search the user requested? I might be making that up though.

    Apologies if this has been done to death

    Heres my code, any help much appreciated as this is driving me up the wall and remember talk very basic to me lol

    PHP Code:
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <!--
    #include file="Connections/DirectoryData.asp" -->

    <script language="JavaScript">
    <!--
    var 
    popup="Sorry, right-click is disabled.";
    function 
    noway(go) {
    if (
    document.all) {
    if (
    event.button == 2) {
    alert(popup);
    return 
    false;
    }
    }
    if (
    document.layers) {
    if (
    go.which == 3) {
    alert(popup);
    return 
    false;
    }
    }
    }
    if (
    document.layers) {
    document.captureEvents(Event.MOUSEDOWN);
    }
    document.onmousedown=noway;
    // --> </script>
    <%
    Dim Recordset1
    Dim search
    Dim where
    search 
    "select * from dbo.DirectoryUsers where "
    firstname ""
    Dim Recordset1_numRows
    %>


    <%


    If 
    Request.Form("firstname") <> "" Then
    where  
    " firstname like '%" Request.Form("firstname") + "%'"
    End If %>

    <%If 
    Request.Form("Surname")  <> "" Then
                where 
    =  " Surname like '%" Request.Form("Surname") + "%'"
    End If %>

    <%If 
    Request.Form("Department")  <> "" Then
     where 
    =  "  Department like '%" Request.Form("Department") + "%'"
    End If %>

    <%If 
    Request.Form("PhoneNumber")  <> "" Then
     where 
    =  "  PhoneNumber like '%" Request.Form("PhoneNumber") + "%'"
    End If %>

    <%

    if 
    where "HideAccount = 'FALSE'" then%>



    <%

        else 
    search search where " ORDER BY Surname, Firstname"
    End if
    %>
    <%
    Set Recordset1 Server.CreateObject("ADODB.Recordset")
    Recordset1.ActiveConnection MM_DirectoryData_STRING
    Recordset1
    .Source search
    Recordset1
    .CursorType 0
    Recordset1
    .CursorLocation 2
    Recordset1
    .LockType 1
    Recordset1
    .Open()
    Recordset1_numRows 0

    %>
    <%
    Dim Repeat1__numRows
    Dim Repeat1__index

    Repeat1__numRows 
    = -1
    Repeat1__index 
    0
    Recordset1_numRows 
    Recordset1_numRows Repeat1__numRows
    %>



    <!
    DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <
    html>
    <
    head>
    <
    meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <
    title>Search Results</title>
    <
    script language="JavaScript" type="text/JavaScript">
    <!--
    function 
    MM_reloadPage(init) {  //reloads the window if Nav4 resized
      
    if (init==truewith (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
        
    document.MM_pgW=innerWidthdocument.MM_pgH=innerHeightonresize=MM_reloadPage; }}
      else if (
    innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgHlocation.reload();
    }
    MM_reloadPage(true);
    //-->
    </script>
    <
    link href="common.css" rel="stylesheet" type="text/css">
    <
    style type="text/css">
    <!--
    .
    style3 {font-familyFuturaSB-Bookfont-weightbold; }
    -->
    </
    style>
    </
    head>

    <
    body>

    <
    div id="Layer1" style="position:absolute; width:656px; height:385px; z-index:1; left: 244px;">
      <
    p>&nbsp;</p>
      <
    p>Click on the Surname to go to full details </p>
      <
    table width="729" height="143" border="1">
        <
    tr bgcolor="#CCCCCC">
          <
    td width="148" height="22" scope="col"><span class="style3">First Name </span></td>
          <
    td width="142" height="22" scope="col"><span class="style3">Last Name </span></td>
          <
    td width="177" height="22" scope="col"><span class="style3">Phone Number </span></td>
          <
    td width="132" height="22" scope="col"><span class="style3">Job Title </span></td>
          <
    td width="96" height="22" scope="col"><span class="style3">Picture</span></td>
        </
    tr>
        <% 


    While ((
    Repeat1__numRows <> 0) AND (NOT Recordset1.EOF)) 
    %>
        <
    tr>
          <
    td scope="row"><%=(Recordset1.Fields.Item("Firstname").Value)%></td>
          <
    td bgcolor="#FFFFFF"><a href="details.asp?IdNo=<%=(Recordset1.Fields.Item("UserID").Value)%>"><%=(Recordset1.Fields.Item("Surname").Value)%></a></td>
          <
    td><%=(Recordset1.Fields.Item("PhoneNumber").Value)%></td>
          <
    td><%=(Recordset1.Fields.Item("Jobtitle").Value)%></td>
          <
    td><img src="images/<%=(Recordset1.Fields.Item("WebPage").Value)%>.jpg" width="95" height="83"></td>
        </
    tr>
        <% 
      
    Repeat1__index=Repeat1__index+1
      Repeat1__numRows
    =Repeat1__numRows-1
      Recordset1
    .MoveNext()
    Wend
    %>

      </
    table>
      
      
      <
    p>&nbsp;</p>
    </
    div>
    <!--
    #include file="navbar.asp" -->
    </body>
    </
    html>
    <%
    Recordset1.Close()
    Set Recordset1 Nothing
    %> 

  • #2
    Where are your previous and next buttons? In the navbar.asp include?

    What you're talking about is called recordset paging, and it's a bit compliated to go into any detail in a forum post. There are some great tutorials out there, though - just bang it into Google and have a read.

    A couple of other observations, however:

    Firstly, you don't need the ASP code delimiters (<% and %>) round each line of ASP. In fact, every time the ASP parser has to flip in and out of ASP code, it'll slow your page down a little. So take out as many of the ASP delimiters as you can.

    Secondly, no-right-click scripts are a waste of time, and serve only as an irritation to users. Don't stop peoples computers behaving the way that they expect them to unless you absolutely have to, and if you don't want people copying your images, don't put them on a website.

    Comment


    • #3
      thanks for the reply, i got it working, it because my submit form was get instead of post!

      Ive tidied the code up now aswell. Cant get rid of the no right click as thats how the powers that be want it. (it drives me mad!)

      Thanks again

      Comment

      Working...
      X