www.webdeveloper.com
Results 1 to 4 of 4

Thread: Move Last, Previous, Next, First Buttons

  1. #1
    Join Date
    Jun 2004
    Location
    Kansas City, MO
    Posts
    1,607

    Move Last, Previous, Next, First Buttons

    WOW, is all i can say.
    I have a bunch of apps that run on the web and just had a user call me and say that the 4 seconds it takes to move to the next record is not acceptable. 4 Fuking seconds come on. Then wanted to know why we did not use like VB to create a intranet instead of web pages. This dude is a complete pain in the ass. Any way i want to look into how i am doing the move next, last, etc and see if i am doing it wrong. I cant believe that i am going to do this for an extra 1-2 seconds of load time, damn i am pissed right now. We have to many end users who need emails to tell them when to **** because if its not automated then they cant do there job. Bunch of lazy a$$ worthless people. Ok, ok its out of my system.

    This is how this is currently working, please let me know if there is a better way
    Code:
    <%
    'this is not the sql statement just an example, the real sql is built on the fly
    'as it builds it self to the search criteria.
    SQL = "SELECT * FROM CUSTOMER"
    objRS.Open, objConn, 3, 3
    if not objRS.EOF then 
         objRS.MoveFirst
         strAction = Request.form("MoveAction")
         Select Case strAction
                   Case "MoveNext"
                             varPosition  = Request.Form("Position")
    		objRS.AbsolutePosition = varPosition
    		objRS.MoveNext
    		If objRS.EOF Then
    		     objRS.MoveFirst
    		End If  
    
                   Case "MovePrev"
                             varPosition  = Request.Form("Position")
    		objRS.AbsolutePosition = varPosition
    		objRS.MovePrevious
    		If objRS.BOF Then
    		    objRS.MoveLast
    		End If  
    
                   Case "MoveLast"
                             varPosition  = Request.Form("Position")
    		objRS.AbsolutePosition = varPosition
    		objRS.MoveLast 
          
                   Case "MoveFirst"
                             varPosition  = Request.Form("Position")
    		objRS.AbsolutePosition = varPosition
    		objRS.MoveFirst
          End Select 
    End if
     %>
    
    <td colspan= 6 >
    	<Input Type=Button Name=cmdFirst Value="<<" title="Move to the First Record">
                 <Input Type=Button Name=cmdDown Value="<|" title="Move to the Previous Record">
    	<input type=label  value="<%=objRS.AbsolutePosition%> of <%=objRS.RecordCount%>" onfocus="blur()" id=label1 name=label1 size=10>
    	<Input Type=Button Name=cmdUp Value="|>" title="Move to the Next Record">
    	<Input Type=Button Name=cmdLast Value=">>" title="Move to the Last Record">
    </td>
    
    
    <!--this is at the very end of the page-->
    <input type=hidden name=sqlWhereClause value="<%=sqlWhereClause%>"> 
    <input Type="Hidden" Size="4" Name="MoveAction" Value="Move">
    <input Type="Hidden" Size="4" Name="Position" Value="<%=objRS.AbsolutePosition%>">
    ok so the first time through the page, i create the where clause to be used. I save that in a hidden text field so i dont have to recreate it everytime the page is submited.

    I also store the absolute position in a hidden text box.

    When i click on the buttons it calles vbscript functions for the button, that basically set the MoveAction textbox with the value of the button that was clicked. Thats about it.

    I think 4 sec is acceptable but they want to see like 2 sec's. Is there a better way to do this or it this what they are going to have to live with.

  2. #2
    Join Date
    Dec 2004
    Posts
    8,637
    What you can do is take a copy of the page and add statements to display how much time is spent at each step in the process (before opening the connection, before building the SQL, before opening the record set, before each movement of the recordset pointer, before closing the recordset, before closing the connection, and before the end of your document). Then you will know where to concentrate your efforts and if there is anything to be done about it.

    Right off the bat, though, you can eliminate that first MoveFirst line. Upon creating a new recordset, the pointer is automatically on the first row already.
    Last edited by phpnovice; 05-03-2005 at 03:38 PM.

  3. #3
    Join Date
    Jun 2004
    Location
    Kansas City, MO
    Posts
    1,607
    ya, i located the problem the page was having. It had nothing to do w/ the code above. One of the search fields is a customer field. Well we have around 1000 customers that get loaded into the drop down. So what i did was, on the inital load, it takes about 4 secs, as it has to load all the customers. This allows you to search by a customer if need be. But after the search i set a boolean to dispaly a text box with the customers name from the DB instead of reloading all the customers into the drop down on each submit. Dropped the load time to 1 sec. So i guess i jumped the gun when i got all pissed at the client. Turns out my code was inefficient. Man am i eating my words now.

  4. #4
    Join Date
    Apr 2005
    Location
    kali
    Posts
    308
    instead of populating a drop down box, i normally provide a link that brings up a window that they can scroll and click the item they want to use in that box. you just need a couple javascript functions and its a lot more user friendly than a plain drop down. it also defers the load of all the customers to that window only if they need it. in a lot of applications that i have done, many of the users know their customer numbers already and just want to type it in. for longer lists i have even used anchor tags at the top of that window for each letter in the alphabet.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles