Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.
helmuth

print doesn't work

by helmuth, Last updated on 4 months ago in Panels and Infusions
I use this code in an custom page - the page is populated with the data it's supposed to show, but the print button does not function?

any ideas why?

 <script type='text/javascript'>
 function printDiv(divName) {
 var printContents = document.getElementById(divName).innerHTML;
 var originalContents = document.body.innerHTML;
 document.body.innerHTML = printContents;
 window.print();
 document.body.innerHTML = originalContents;
 }
 </script>
<?php
$result = dbquery(
 "SELECT user_id as user_id, user_name, user_email, user_phone_mobile, user_phone_home, user_geo
 FROM ************_users // altered the correct name with *
 WHERE user_status = 0 ORDER BY user_name ASC"
 );
 echo "<div id='printableArea'>";
 if (dbrows($result)) {
while ($data = dbarray($result)) {

if (!empty($data['user_geo'])) {
$a = explode("|", $data['user_geo']); // it becomes array and it will break into 6 parts
$street1 = $a[0];
$street2 = $a[1];
$country = $a[3];
$region = $a[4];
$city = $a[5];
$zip = $a[6];
$data['user_geo'] = "$street1, $street2, $city, $region, $country, $zip";
}
echo "<div class='list-group-item'>Navn: <strong> ".$data['user_name']."</strong><br/></div> ";
echo "<div class='list-group-item'>Mail: <strong> ".$data['user_email']."</strong><br/></div> ";
echo "<div class='list-group-item'>Mobil: <strong> ".$data['user_phone_mobile']."</strong><br/></div> ";
echo "<div class='list-group-item'>Tlf.: <strong> ".$data['user_phone_home']."</strong><br/></div> ";
echo "<div class='list-group-item'>Adresse: <strong> ".$data['user_geo']."</strong><br/></div> ";
echo "<div class='list-group-item'><br/></div> ";
}
 } else {
 echo "No data in table.";
 }
echo "<input type='button' onclick='printDiv(\"printableArea\")' value='Udskriv side' /></div>";
?>
All people are born alike - except Republicans and Democrats.
Groucho Marx
-----------------------------------------
Try,

<script type='text/javascript'>
   function printDiv(divName) {
         var printContents = document.getElementById(divName).innerHTML;
         var originalContents = document.body.innerHTML;
         document.body.innerHTML = printContents;
         window.print();
         document.body.innerHTML = originalContents;
   }
</script>
 
<?php
   $result = dbquery("
   SELECT user_id as user_id, user_name, user_email, user_phone_mobile, user_phone_home, user_geo
   FROM ************_users // altered the correct name with *
   WHERE user_status = 0 ORDER BY user_name ASC"
   );

echo "<div id='printableArea'>";
   if (dbrows($result)) {
      while ($data = dbarray($result)) {

         if (!empty($data['user_geo'])) {
         $a = explode("|", $data['user_geo']); // it becomes array and it will break into 6 parts
         $street1 = $a[0];
         $street2 = $a[1];
         $country = $a[3];
         $region = $a[4];
         $city = $a[5];
         $zip = $a[6];
         $data['user_geo'] = "$street1, $street2, $city, $region, $country, $zip";
         }
   echo "<div class='list-group-item'>Navn: <strong> ".$data['user_name']."</strong><br/></div> ";
   echo "<div class='list-group-item'>Mail: <strong> ".$data['user_email']."</strong><br/></div> ";
   echo "<div class='list-group-item'>Mobil: <strong> ".$data['user_phone_mobile']."</strong><br/></div> ";
   echo "<div class='list-group-item'>Tlf.: <strong> ".$data['user_phone_home']."</strong><br/></div> ";
   echo "<div class='list-group-item'>Adresse: <strong> ".$data['user_geo']."</strong><br/></div> ";
   echo "<div class='list-group-item'><br/></div> ";
      }
   } else {
   echo "No data in table.";
}
echo "</div>";
echo "<input type='button' onclick='printDiv(\"printableArea\")' value='Udskriv side' />";
?>
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Please read and comply with the Code of Conduct

(¯`·._.·(¯`°·._.·°º*[ Project Manager ]*º°·._.·°´¯)·._.·´¯)
I tried the code - tested it in Chrome, Opera, Firefox and Safari

neither of them worked

clicking the print button has only the mouse-over effect :-(
All people are born alike - except Republicans and Democrats.
Groucho Marx
-----------------------------------------
Try place
<script type='text/javascript'>
 function printDiv(divName) {
 var printContents = document.getElementById(divName).innerHTML;
 var originalContents = document.body.innerHTML;
 document.body.innerHTML = printContents;
 window.print();
 document.body.innerHTML = originalContents;
 }
</script>
 


Last in the file.
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Please read and comply with the Code of Conduct

(¯`·._.·(¯`°·._.·°º*[ Project Manager ]*º°·._.·°´¯)·._.·´¯)
helmuth has replied to this - 4 months ago
tested ... but sorry to say, it made no difference - no pop up to print :-(
All people are born alike - except Republicans and Democrats.
Groucho Marx
-----------------------------------------
You can view all discussion threads in this forum.
You can start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You can download attachments in this forum.
Users who participated in discussion: helmuth, Falk