title: print paginated table (simplePagination.js by flaviusmatis)
body: <p><div class="snippet" data-lang="js" data-hide="true" data-console="false" data-babel="false">
  <div class="snippet-code snippet-currently-hidden">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var search;
  
  var searchdiv = $("#searchdiv");
  var perPage = 3;
  searchdiv.pagination({
    itemsOnPage: perPage,
    cssStyle: "light-theme",
    onPageClick: function(pageNumber) {
      var showFrom = perPage * (pageNumber - 1);
      var showTo = showFrom + perPage;
  
      search.hide()
        .slice(showFrom, showTo).show();
    }
  });
  
  function updateItems() {
    search = $(".geoname");
    searchdiv.pagination("updateItems", search.length);
    var page = Math.min(
      searchdiv.pagination("getCurrentPage"),
      searchdiv.pagination("getPagesCount")
  
    );
  
    searchdiv.pagination("selectPage", page);
  }
  updateItems();
  
  var geo = {
    "geonames": [{
      "lng": -99.12766456604,
      "geonameId": 3530597,
      "countrycode": "MX",
      "name": "Mexiko-Stadt",
      "fclName": "city, village,...",
      "toponymName": "Mexico City",
      "fcodeName": "capital of a political entity",
      "wikipedia": "en.wikipedia.org/wiki/Mexico_City",
      "lat": 19.428472427036,
      "fcl": "P",
      "population": 12294193,
      "fcode": "PPLC"
    }, {
      "lng": 116.397228240967,
      "geonameId": 1816670,
      "countrycode": "CN",
      "name": "Peking",
      "fclName": "city, village,...",
      "toponymName": "Beijing",
      "fcodeName": "capital of a political entity",
      "wikipedia": "en.wikipedia.org/wiki/Beijing",
      "lat": 39.9074977414405,
      "fcl": "P",
      "population": 11716620,
      "fcode": "PPLC"
    }, {
      "lng": 120.9822,
      "geonameId": 1701668,
      "countrycode": "PH",
      "name": "Manila",
      "fclName": "city, village,...",
      "toponymName": "Manila",
      "fcodeName": "capital of a political entity",
      "wikipedia": "en.wikipedia.org/wiki/Manila",
      "lat": 14.6042,
      "fcl": "P",
      "population": 10444527,
      "fcode": "PPLC"
    }, {
      "lng": 90.40743827819824,
      "geonameId": 1185241,
      "countrycode": "BD",
      "name": "Dhaka",
      "fclName": "city, village,...",
      "toponymName": "Dhaka",
      "fcodeName": "capital of a political entity",
      "wikipedia": "en.wikipedia.org/wiki/Dhaka",
      "lat": 23.710395616597037,
      "fcl": "P",
      "population": 10356500,
      "fcode": "PPLC"
    }, {
      "lng": 126.9784,
      "geonameId": 1835848,
      "countrycode": "KR",
      "name": "Seoul",
      "fclName": "city, village,...",
      "toponymName": "Seoul",
      "fcodeName": "capital of a political entity",
      "wikipedia": "en.wikipedia.org/wiki/Seoul",
      "lat": 37.566,
      "fcl": "P",
      "population": 10349312,
      "fcode": "PPLC"
    }, {
      "lng": 106.84513092041016,
      "geonameId": 1642911,
      "countrycode": "ID",
      "name": "Jakarta",
      "fclName": "city, village,...",
      "toponymName": "Jakarta",
      "fcodeName": "capital of a political entity",
      "wikipedia": "en.wikipedia.org/wiki/Jakarta",
      "lat": -6.214623197035775,
      "fcl": "P",
      "population": 8540121,
      "fcode": "PPLC"
    }, {
      "lng": 139.69171,
      "geonameId": 1850147,
      "countrycode": "JP",
      "name": "Tokyo",
      "fclName": "city, village,...",
      "toponymName": "Tokyo",
      "fcodeName": "capital of a political entity",
      "wikipedia": "de.wikipedia.org/wiki/Tokyo",
      "lat": 35.6895,
      "fcl": "P",
      "population": 8336599,
      "fcode": "PPLC"
    }, {
      "lng": 121.531846,
      "geonameId": 1668341,
      "countrycode": "TW",
      "name": "Taipeh",
      "fclName": "city, village,...",
      "toponymName": "Taipei",
      "fcodeName": "capital of a political entity",
      "wikipedia": "de.wikipedia.org/wiki/Taipei",
      "lat": 25.047763,
      "fcl": "P",
      "population": 7871900,
      "fcode": "PPLC"
    }, {
      "lng": -74.08175468444824,
      "geonameId": 3688689,
      "countrycode": "CO",
      "name": "Bogotá",
      "fclName": "city, village,...",
      "toponymName": "Bogotá",
      "fcodeName": "capital of a political entity",
      "wikipedia": "en.wikipedia.org/wiki/Bogot%C3%A1",
      "lat": 4.609705849789108,
      "fcl": "P",
      "population": 7674366,
      "fcode": "PPLC"
    }, {
      "lng": 114.157691001892,
      "geonameId": 1819729,
      "countrycode": "HK",
      "name": "Hong Kong",
      "fclName": "city, village,...",
      "toponymName": "Hong Kong",
      "fcodeName": "capital of a political entity",
      "wikipedia": "en.wikipedia.org/wiki/Hong_Kong",
      "lat": 22.2855225817732,
      "fcl": "P",
      "population": 7012738,
      "fcode": "PPLC"
    }]
  }
  
  geonames = geo.geonames;
  
  var data = geonames;
  
  
  for (var i = 0; i &lt; data.length; i++) {
    tr = $('&lt;tr class=geoname/&gt;');
    if (data[i].geonameId) {
      tr.append("&lt;td id=''&gt;" + data[i].name + "&lt;/td&gt;");
      tr.append("&lt;td id=''&gt;" + data[i].countrycode + "&lt;/td&gt;");
      tr.append("&lt;td id=''&gt;" + data[i].lng + "&lt;/td&gt;");
      tr.append("&lt;td id=''&gt;" + data[i].lat + "&lt;/td&gt;");
      tr.append("&lt;td id=''&gt;" + data[i].population + "&lt;/td&gt;");
      tr.append("&lt;td id=''&gt;" + data[i].geonameId + "&lt;/td&gt;");
  
      tr.append("&lt;td id=''&gt;" + "&lt;a class=geonameview  id=" + data[i].geonameId + " href='#' &gt;View Details&lt;/a&gt;" + "&lt;/td&gt;");
  
    } else {
      tr.append("&lt;td id=''&gt;&lt;/td&gt;");
      tr.append("&lt;td id=''&gt;&lt;/td&gt;");
      tr.append("&lt;td id=''&gt;&lt;/td&gt;");
      tr.append("&lt;td id=''&gt;&lt;/td&gt;");
      tr.append("&lt;td id=''&gt;&lt;/td&gt;");
      tr.append("&lt;td id=''&gt;&lt;/td&gt;");
      tr.append("&lt;td id=''&gt;&lt;/td&gt;");
  
    }
  
    $("#geonames").append(tr);
  }
  updateItems();
  
  
  
  
  
  
  
  
  
  function printpage() {
    window.print();
  }</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>@media print {
    .dontprint {
      display: none
    }
    body {
      display: block;
    }
  }
  body {
    display: block;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;link type="text/css" rel="stylesheet" href="https://rawgit.com/flaviusmatis/simplePagination.js/master/simplePagination.css"&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://rawgit.com/flaviusmatis/simplePagination.js/master/jquery.simplePagination.js"&gt;&lt;/script&gt;
  
  
  
  &lt;table id="geonames" class="searchresult" border="1"&gt;
    &lt;tr id=""&gt;
      &lt;th&gt;
        Name
      &lt;/th&gt;
      &lt;th&gt;
        Country Code
      &lt;/th&gt;
      &lt;th&gt;
        Longitude
      &lt;/th&gt;
      &lt;th&gt;
        Latitude
      &lt;/th&gt;
      &lt;th&gt;
        Population
      &lt;/th&gt;
      &lt;th&gt;
        ID
      &lt;/th&gt;
      &lt;th&gt;
        Action
      &lt;/th&gt;
    &lt;/tr&gt;
  
  &lt;/table&gt;
  &lt;div id="searchdiv" class="dontprint"&gt;&lt;/div&gt;
  &lt;button onclick="printpage()" class="dontprint" style="float: right"&gt;Print Preview&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Using </p>
  
  <pre><code>$('.printMe').click(function(){
       window.print();
  });
  </code></pre>
  
  <p>I can print entire screen. In my screen i have a table which is paginated using the <a href="http://flaviusmatis.github.io/simplePagination.js/" rel="nofollow noreferrer">flaviusmatis Simple Pagination</a>. So i have buttons in the table. I added </p>
  
  <pre><code>.dontprint{ 
      display : none
  }
  </code></pre>
  
  <p>for elements that i dont need to print that includes the button in the pagination. </p>
  
  <p><strong>If i have 50 pages that is so much click and waste of time.</strong></p>
  
  <p><strong>Note</strong></p>
  
  <p>I. As much as possible I don't want to use other than this pagination but if there are no option then I have no choice but use other pagination function with print function with them.</p>
  
  <p><strong>Current Function</strong></p>
  
  <p>Right now what I have to do is print them one by one. <em>I need to click to page 1 click print click page 2 click print and so on...</em></p>
  
  <p><strong>Aim Function</strong></p>
  
  <p>Have a button that lets user print all the paginated pages on one click.</p>
  
  <p><strong>Possible Approach</strong></p>
  
  <p>On button click find button with active class(in the paginated pages) click print button (in code) then click on next button (in code) then click print (in code) and so until the last page. <em>still working on this one</em></p>
  
  <p><strong>Question</strong></p>
  
  <ol>
  <li>Is there a way where I can just click one button and be able to print all the paginated pages. </li>
  <li>If I have say 20 pages that will be at least 39 click and <strong>I am not sure if it will cause the page to shut down</strong>(if possible approach is done)</li>
  </ol>
  
  <p><strong>Update</strong></p>
  
  <p>I don't want to print all the pages into one. What I want is print the pages as it is. Meaning each page separately from other pages. <em>I hope I am making sense</em></p>