#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2002
    Posts
    20
    Rep Power
    0

    displaying 10 rows in each page and creates a new form if it exceeds that page


    I'm trying to create a form that does the following in jsp/javascript

    Displays 10 rows, each row containing a record
    if records exceeds 10, it will display the remaining records on another page.The first form will contain a link to the second form and the second form will contain the link to the first. So basically there could be infinite number of forms containing 10 rows each on each form each displaying a link to the other forms.

    Help

    Comments on this post

    • BaronVonDoppleG agrees
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2002
    Location
    Vienna, Austria
    Posts
    13
    Rep Power
    0
    not jsp/javascript, but maybe it helps ...
    Code:
    $index = $q->params('i'); #first page is called with i=1
    $max = ???; #number of rows
    $MAXROWS = 10;
    
    $end = $max;
    $next = 0;
    if (($max - $index) >= $MAXROWS) {
      $end = $index + $MAXROWS - 1;
      $next = 1;
    }
    
    #rows
    for ($i = $index; $i <= $end; $i++) {
      print $rows[$i - 1]; #if first elements index is 0
    }
    
    #prev-link
    if ($index > 1) {
      $j = $index - $MAXROWS;
      if ($j < 1) {
        $j = 1;
      }
      print "<a href='http://url?i=$j'>Prev</a>";
    }
    
    #direct links
    if ($max > $MAXROWS) {
      for ($i = 1; $i <= $max; $i = $i + $MAXROWS) {
        if (($i >= $index) && ($i < ($index + $MAXROWS))) {
          print " $i "; #actual page is not a link
        } else {
          print " <a href='http://url?i=$i'>$i</a> ";
        }
      }
    }
    
    #next link
    if ($next) {
      print "<a href='http://url?i=" . ($end + 1) . "'>Next</a>";
    }
    sorry, but i had no time to test the code. maybe you have to add somewhere a +/- 1 or so
    Last edited by Hermetiker; February 27th, 2002 at 07:57 AM.

IMN logo majestic logo threadwatch logo seochat tools logo