Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 7th, 2006, 02:23 AM
Registered User
 
Join Date: Jun 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to use javascript in pagination

hi,

 i tried pagination code which i get in net, i have 20 records.i want to display 5 records per page.first time it will display first 5 records if i click the next button it will display the same first 5 records but i want to display next 5 records. it will not increment the page. the below is the pagination code which i used,pls give the solution i dont know where i use javascript to increment the page value which i used in parameter.


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="3.2" encoding="ISO-8859-1"/>
<xsl:param name="Page" select="1" />
<xsl:param name="PageSize" select="5" />
<xsl:template match="/">
<P><xsl:variable name="mycount" select="count(EmployeeDetails/PersonalDetails)"/>
<xsl:variable name="selectedRowCount" select="round($mycount div $PageSize)"/>
</P>
<html>
<body>
<form name="frmEmployeeList" action="EmployeeDetails.xml" method="post">
<link type="text/css" rel="StyleSheet" href="D:/Program Files/Apache Software Foundation/Tomcat 5.5/webapps/PayDemo/css/table.css"/>
<center><b>Employee Details</b></center>
<br/>
<table class="Search" align="center" >
<tr>
<td width="35%"></td>
<td>Search:</td>
<td><input name="txtSearch"/></td>
<td><button>Search</button></td>
<td width="35%"></td>
</tr>
</table>
<br/>
          <table class="EmployeeList" border="1" cellspacing="0" cellpading="0" align="center" bordercolor="rgb(120,172,255)">
                <thead>
                    <th></th>
                    <th>Employee Number</th>
                    <th>Employee Name</th>
                    <th>Date of Birth</th>
                    <th>Father Name</th>
                    <th>Address</th>
                    <th>************</th>
                    <th>Telephone Number</th>
                    <th>Married</th>
                    <th>No. of Children</th>
                    <th>Blood Group</th>
                    <th>Qualification</th>
                    <th>Paid Every</th>
                    <th>Current Cycle</th>
                </thead>
     <xsl:for-each select="EmployeeDetails/PersonalDetails">
       <xsl:sort select="EmployeeName"/>
           <xsl:if test="position() &gt;= ($Page * $PageSize) + 1">
             <xsl:if test="position() &lt;= $PageSize + ($PageSize * $Page)">
                  <tr>
                     <xsl:attribute name="class">
                         <xsl:choose>
                            <xsl:when test="position()mod 2">odd</xsl:when>
                              <xsl:otherwise>even</xsl:otherwise>
                           </xsl:choose>
                     </xsl:attribute>

                   <td><INPUT TYPE="CHECKBOX"><xsl:attribute name="UNCHECKED"/></INPUT></td>
                    <td><a href="EmployeeDetail.xml"><xsl:value-of select="EmployeeNumber"/></a></td>
                   <td><xsl:value-of select="EmployeeName"/></td>
                   <td><xsl:value-of select="DateofBirth"/></td>
                   <td><xsl:value-of select="Father"/></td>
                   <td><xsl:value-of select="Address"/></td>
                   <td><xsl:value-of select="************"/></td>
                   <td><xsl:value-of select="TelephoneNumber"/></td>
                   <td><xsl:value-of select="Married"/></td>
                   <td><xsl:value-of select="NumberofChildren"/></td>
                   <td><xsl:value-of select="BloodGroup"/></td>
                   <td><xsl:value-of select="Qualification"/></td>
                   <td><xsl:value-of select="PaidEvery"/></td>
                   <td><xsl:value-of select="CurrentCycle"/></td>
               </tr>
          </xsl:if>
        </xsl:if>
  </xsl:for-each>
 </table>

  <xsl:choose>
     <xsl:when test="number($Page)-1 &gt;= 0">#160;
       <A>
         <xsl:attribute name="href">EmployeeDetails.xml?Page=<xsl:value-of select="number($Page)-1"/>&amp;
             pagesize=<xsl:value-of select="$PageSize"/>
         </xsl:attribute>&lt;&lt;Prev
       </A>
       </xsl:when>
       <xsl:otherwise>
           <xsl:message>No Previous Record Found</xsl:message>
       </xsl:otherwise>
  </xsl:choose>

      <xsl:if test="$selectedRowCount &gt; 1">#160;
        <b class="blacktext">
          <xsl:value-of select="number($Page)+1"/>#160;of#160;
          <xsl:value-of select="number($selectedRowCount)"/>
        </b>#160;
      </xsl:if>

      <xsl:choose>
       <xsl:when test="number($Page)+1 &lt; number($selectedRowCount)">#160;
        <A>
           <xsl:attribute name="href">EmployeeDetails.xml?Page=<xsl:value-of select="number($Page)+1"/>&amp;PageSize=<xsl:value-of select="$PageSize"/>&amp;selectedRowCount=<xsl:value-of select="$selectedRowCount"/>
           </xsl:attribute>Next&gt;&gt;
        </A>
       </xsl:when>
       <xsl:otherwise>
          <xsl:message>No Next Record Found</xsl:message>
       </xsl:otherwise>
      </xsl:choose>
<br/>
<table align="center">
<tr>
<td><button onClick="addEmployee()">ADD</button></td>
<td></td>
<td><button>MODIFY</button></td>
<td></td>
<td><button>DELETE</button></td>
</tr>
</table>
</form>
</body>
</html>
</xsl:template>
</xsl:stylesheet>


 
Old June 7th, 2006, 02:37 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

This code looks as if it is server-based, in that it's constructing a URL with query parameters to support the "next" and "previous" links. Is your transformation running server-side? If not, you'll need to modify it so that instead of constructing a URL, it constructs a Javascript call to a function in your HTML page that invokes a new transformation.

If you can't afford to buy my book, try searching for tutorials on client-side XSLT. There are plenty around, though they are mixed quality.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old June 7th, 2006, 04:15 AM
Registered User
 
Join Date: Jun 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i dont know i just copy the code and tried. ok i want to run in client side. how to use javascript.i need javascript coding.if u know pls give the solution.

 
Old June 7th, 2006, 09:59 AM
Registered User
 
Join Date: Jun 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I just signed up for this for myself.

Is this a forum designed to actually help developers and advance knowledge, or is just an avenue for writers to plug their books?

I understand that it's a publisher drivien site, but what's the point of having people post questions if the answer is going to be "buy my book." ??
 
Old June 7th, 2006, 02:13 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Unfortunately there are very few people answering questions on this forum - Joe Gorman and myself, essentially. I'm under no obligation to help here, no one pays me for it. I answer questions when I can do so within a couple of minutes. That's usually possible if it's a direct and simple question. If people say "please write a stylesheet for me", or "please teach me about client-side XSLT programming", then sorry, that's out of scope.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old June 8th, 2006, 07:22 AM
Registered User
 
Join Date: Jun 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for your candid answer Michael.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Pagination with checkboxes argan Pro JSP 2 November 28th, 2008 12:48 AM
grouping and pagination sasidhar79 Crystal Reports 1 December 6th, 2005 01:12 PM
pagination Regornil Pro JSP 2 May 31st, 2005 06:10 AM
Please.....Pagination junemo PHP Databases 2 September 25th, 2004 01:14 PM
pagination junemo Oracle 0 July 1st, 2004 04:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.