By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,700 Members | 1,364 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,700 IT Pros & Developers. It's quick & easy.

Console is undefined error

P: 7
ERROR IS IN console.log(columnWidth); THIS PART PLS CHECK IN CODE PLS TELL ME WHAT TOBE DONE IF I APPLIED IN OTHER WAY FROM INTERNET.

Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. require_once realpath(APPLICATION_PATH .  '/services/Constants.php');
  3. require_once realpath(APPLICATION_PATH .  '/services/CDHelper.php');
  4.  
  5. ?>
  6. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  7. <html xmlns="http://www.w3.org/1999/xhtml">
  8.     <head>
  9.         <title>C+D Phone Reporting System</title>
  10.         <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type" />
  11.         <link rel="stylesheet" type="text/css" href="/Style/Style1.css" media="all" />
  12.         <script language="javascript" type="text/javascript" src="/javascript/cdreporting.js"></script>
  13.         <script language="javascript" type="text/javascript" src="/javascript/jquery-1.6.4.min.js"></script>
  14.  
  15.  
  16.  
  17. <script>
  18. $(window).load(function() {
  19.     var columnWidth = 0;
  20.     var docwidth = $(document).width();
  21.     $('.header div').each(function(){
  22.         columnWidth+=parseInt($(this).width());
  23.     })
  24.     $('#myTable').width(columnWidth);
  25.     console.log(columnWidth);
  26.  
  27.  
  28. });
  29. </script>
  30.     </head>
  31.     <body>
  32.         <form name="form" method="post">
  33.  
  34. <?php 
  35.             $count = Count($this->paginator);        
  36.             if($count != '0'){ 
  37. ?>
  38. <div style="float: left;overflow-x: scroll; width: 100%; height: 650px; background-color:#ffffff;">
  39. <div>
  40.     <div class="gen-462" align="right"><a href="javascript: self.close ()"><strong>Close</strong></a>&nbsp;&nbsp;</div>
  41. <div>
  42.     <div class="reps-4-1hCR">
  43.     <div align="center" class="Hed reps-4-1p"></div>
  44.   </div>
  45. </div>
  46. </div>  
  47.   <table border="0" cellspacing="0" cellpadding="0" id="myTable">
  48.   <tr><td>
  49.     <div align="center" class="Hed"><input type="hidden" name="pageno" id="pageno" value="1"></input>Course Report</div>
  50.     <div align="center" class="Hed">
  51.         <hr noshade="noshade"  />
  52.     </div>
  53.   </td></tr>
  54.     <tr valign="top">
  55.         <td><div class="header">
  56.           <div class="feed-header-slno"><strong>Sl No</strong></div>
  57.           <div class="feed-header"><strong class="gen-461">First Name</strong></div>
  58.           <div class="feed-header"><strong class="gen-461">Surname</strong></div>
  59.           <div class="feed-header"><strong class="gen-461">Modules Attempted</strong></div>
  60. <?php foreach ($this->moduleheader as $moduledetails) {?>
  61.                         <div class="feed-header"><strong class="gen-461"><?php echo $moduledetails['name'] . ' Result'; ?></strong></div>
  62.                         <div class="feed-header"><strong class="gen-461"><?php echo $moduledetails['name'] . ' No of times Attempted'; ?></strong></div>
  63.                         <div class="feed-header"><strong class="gen-461"><?php echo $moduledetails['name'] . ' Score'; ?></strong></div>
  64.                         <div class="feed-header"><strong class="gen-461"><?php echo $moduledetails['name'] . ' Attempted Date'; ?></strong></div>
  65. <?php } ?>
  66.         </div></td>
  67.     </tr>
  68.     <tr>
  69.       <td>
  70. <?php 
  71. //            $count = Count($this->paginator);        
  72. //            if($count != '0'){ 
  73.              $slno = ($this->paginator->getCurrentPageNumber() * 10) - 9;
  74.             $i = 0;
  75.             $prevName = '';
  76.             $prevPin  = '';
  77.  
  78.             foreach($this->paginator as $coursereportdetails){
  79.                     if($coursereportdetails['pass'] == 1){
  80.                         $modulePassRFail = 'Pass';
  81.                     } else if($coursereportdetails['pass'] == 0 && $coursereportdetails['score'] != '') {
  82.                         $modulePassRFail = 'Fail';
  83.                     } else if($coursereportdetails['pass'] == 0 && $coursereportdetails['score'] == '') {
  84.                         $modulePassRFail = '';
  85.                     }
  86.                     if($coursereportdetails['attempteddate'] == ''){
  87.                         $attemptedDate = '';
  88.                     } else {
  89.                         $attemptedDate = CDHelper::toYMDDate($coursereportdetails['attempteddate']);
  90.                     }
  91.         if($i != 0){
  92.             $name = $coursereportdetails['firstname'].$coursereportdetails['surname'];
  93.             if(!($name == $prevName && $coursereportdetails['pinno'] == $prevPin)) {
  94.                 echo "</div>";
  95.                 $slno++; ?>
  96. <?php            $j = fmod($slno,'2');
  97.                 if($j != '0') {
  98. ?>
  99.                 <div class="data-1">
  100. <?php             } else { ?>
  101.                 <div class="data-2">
  102. <?php } ?>
  103.                 <div class="feed-data-slno"><?php echo $slno; ?></div>
  104.                 <div class="feed-data"><?php echo $coursereportdetails['firstname']; ?></div>
  105.                 <div class="feed-data"><?php echo $coursereportdetails['surname']; ?></div>
  106.                 <div class="feed-data"><?php echo $coursereportdetails['modulesattempted']; ?></div>
  107.                 <div class="feed-data"><?php echo $modulePassRFail; ?></div>
  108.                 <div class="feed-data"><?php echo $coursereportdetails['attempt']; ?></div>
  109.                 <div class="feed-data"><?php echo $coursereportdetails['score']; ?></div>
  110.                 <div class="feed-data"><?php echo $attemptedDate; ?></div>
  111. <?php            $prevName = $coursereportdetails['firstname'] . $coursereportdetails['surname'];
  112.                 $prevPin  = $coursereportdetails['pinno'];
  113.  
  114.             } else { ?>
  115.                 <div class="feed-data"><?php echo $modulePassRFail; ?></div>
  116.                 <div class="feed-data"><?php echo $coursereportdetails['attempt']; ?></div>
  117.                 <div class="feed-data"><?php echo $coursereportdetails['score']; ?></div>
  118.                 <div class="feed-data"><?php echo $attemptedDate; ?></div>
  119. <?php            $prevName = $coursereportdetails['firstname'] . $coursereportdetails['surname'];
  120.                 $prevPin  = $coursereportdetails['pinno'];
  121.             }
  122.         } else { ?>
  123.             <div class="data-1">
  124.                 <div class="feed-data-slno"><?php echo $slno; ?></div>
  125.                 <div class="feed-data"><?php echo $coursereportdetails['firstname']; ?></div>
  126.                 <div class="feed-data"><?php echo $coursereportdetails['surname']; ?></div>
  127.                 <div class="feed-data"><?php echo $coursereportdetails['modulesattempted']; ?></div>
  128.                 <div class="feed-data"><?php echo $modulePassRFail; ?></div>
  129.                 <div class="feed-data"><?php echo $coursereportdetails['attempt']; ?></div>
  130.                 <div class="feed-data"><?php echo $coursereportdetails['score']; ?></div>
  131.                 <div class="feed-data"><?php echo $attemptedDate; ?></div>
  132. <?php            $prevName = $coursereportdetails['firstname'] . $coursereportdetails['surname'];
  133.                 $prevPin  = $coursereportdetails['pinno'];
  134.         }
  135.         $i++;
  136.  } ?>
  137.  
  138.  
  139.                     <div align="right" class="td resreps-8-151CR"><?php if($count != '0'){ echo $this->paginator; }?></div>
  140.       </td>
  141.     </tr>
  142.             <?php } else { ?>
  143.             <br></br><br></br><br></br><br></br><br></br>
  144.                 <div align="center"><font color="red" size="2"><?php echo RECORDS_NOT_FOUND; ?></font></div>
  145.                 <br></br><br></br><br></br>
  146.                 <?php } ?>            
  147.   </table>
  148. </div>
  149.  
  150.             <!--Main div Ends-->
  151.         </form>
  152.     </body>
  153. </html>
  154.  
Nov 16 '11 #1
Share this Question
Share on Google+
1 Reply


Dormilich
Expert Mod 5K+
P: 8,639
it just means that in your browser there is no console object.

a quick’n’dirty fix can at least prevent some of the errors:
Expand|Select|Wrap|Line Numbers
  1. // prevents errors when directly calling console & console.log()
  2. if (typeof console === "undefined" || null === console) {
  3.     console = {
  4.         log: function() {}
  5.     }
  6. }
Nov 16 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.