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.
Not a member yet? Click here to register.
Forgot Password?

print doesn't work

Asked Modified Viewed 2,270 times
H
helmuth
H
Danish translator of PHP-Fusion helmuth@php-fusion.dk
-----------------------------------------
All people are born alike - except Republicans and Democrats. (Groucho Marx)
Listen to the music... https://soundcloud.com/helmuth-mikkel...mikkelsen/
  • Senior Member, joined since
  • Contributed 706 posts on the community forums.
  • Started 219 threads in the forums
  • Started this discussions
  • Answered 1 question
asked
Senior Member

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>";
?>
0 replies

3 posts

F
Falk
F
Falk 131
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Answered 11 questions
answered
Super Admin

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' />";
?>
0 replies
H
helmuth
H
Danish translator of PHP-Fusion helmuth@php-fusion.dk
-----------------------------------------
All people are born alike - except Republicans and Democrats. (Groucho Marx)
Listen to the music... https://soundcloud.com/helmuth-mikkel...mikkelsen/
  • Senior Member, joined since
  • Contributed 706 posts on the community forums.
  • Started 219 threads in the forums
  • Started this discussions
  • Answered 1 question
answered
Senior Member

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 :-(
0 replies
F
Falk
F
Falk 131
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Answered 11 questions
answered
Super Admin

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.
1 reply

Category Forum

Panels and Infusions

Statistics

  • Views 0 views
  • Posts 3 posts
  • Votes 0 votes
  • Topic users 2 members

2 participants

F
F
Falk 131
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Answered 11 questions
H
H
Danish translator of PHP-Fusion helmuth@php-fusion.dk
-----------------------------------------
All people are born alike - except Republicans and Democrats. (Groucho Marx)
Listen to the music... https://soundcloud.com/helmuth-mikkel...mikkelsen/
  • Senior Member, joined since
  • Contributed 706 posts on the community forums.
  • Started 219 threads in the forums
  • Started this discussions
  • Answered 1 question

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet