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.

print doesn't work


Print Track
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>";
?>

4 replies

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' />";
?>
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 :-(
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.
helmuth has replied to this - 9 months ago
tested ... but sorry to say, it made no difference - no pop up to print :-(
author helmuth
forumPanels and Infusions
replies5 posts
viewed752 times
activeLast updated on 9 months ago

Related

Php include dont work in php fusion?
Started by
L
LiTos456 - 12 posts
Some locale don't "work" when upgrading
Started by
M
mojkan - 1 post
Date and time difference time does not work
Started by Algeciras Algeciras - 4 posts
Can not get Albums with sub albums to work
Started by
B
Bluey100 - 1 post
"$" used in $db_pass won't work
Started by kneekoo kneekoo - 2 posts
Articels no of shown Articels dont work right
Started by DosSpiele DosSpiele - 4 posts
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: Falk, helmuth