Console is undefined error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fareednn
    New Member
    • Oct 2011
    • 7

    Console is undefined error

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

    Code:
    <?php 
    require_once realpath(APPLICATION_PATH .  '/services/Constants.php');
    require_once realpath(APPLICATION_PATH .  '/services/CDHelper.php');
    
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    	<head>
    		<title>C+D Phone Reporting System</title>
    		<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type" />
    		<link rel="stylesheet" type="text/css" href="/Style/Style1.css" media="all" />
    		<script language="javascript" type="text/javascript" src="/javascript/cdreporting.js"></script>
    		<script language="javascript" type="text/javascript" src="/javascript/jquery-1.6.4.min.js"></script>
    		
    
    
    <script>
    $(window).load(function() {
    	var columnWidth = 0;
    	var docwidth = $(document).width();
    	$('.header div').each(function(){
    		columnWidth+=parseInt($(this).width());
    	})
    	$('#myTable').width(columnWidth);
    	console.log(columnWidth);
    
    		
    });
    </script>
    	</head>
    	<body>
    		<form name="form" method="post">
    
    <?php 
    			$count = Count($this->paginator);		
    			if($count != '0'){ 
    ?>
    <div style="float: left;overflow-x: scroll; width: 100%; height: 650px; background-color:#ffffff;">
    <div>
    	<div class="gen-462" align="right"><a href="javascript: self.close ()"><strong>Close</strong></a>&nbsp;&nbsp;</div>
    <div>
    	<div class="reps-4-1hCR">
    	<div align="center" class="Hed reps-4-1p"></div>
      </div>
    </div>
    </div>  
      <table border="0" cellspacing="0" cellpadding="0" id="myTable">
      <tr><td>
    	<div align="center" class="Hed"><input type="hidden" name="pageno" id="pageno" value="1"></input>Course Report</div>
        <div align="center" class="Hed">
            <hr noshade="noshade"  />
        </div>
      </td></tr>
        <tr valign="top">
    		<td><div class="header">
              <div class="feed-header-slno"><strong>Sl No</strong></div>
              <div class="feed-header"><strong class="gen-461">First Name</strong></div>
              <div class="feed-header"><strong class="gen-461">Surname</strong></div>
              <div class="feed-header"><strong class="gen-461">Modules Attempted</strong></div>
    <?php foreach ($this->moduleheader as $moduledetails) {?>
    						<div class="feed-header"><strong class="gen-461"><?php echo $moduledetails['name'] . ' Result'; ?></strong></div>
    						<div class="feed-header"><strong class="gen-461"><?php echo $moduledetails['name'] . ' No of times Attempted'; ?></strong></div>
    						<div class="feed-header"><strong class="gen-461"><?php echo $moduledetails['name'] . ' Score'; ?></strong></div>
    						<div class="feed-header"><strong class="gen-461"><?php echo $moduledetails['name'] . ' Attempted Date'; ?></strong></div>
    <?php } ?>
            </div></td>
        </tr>
        <tr>
          <td>
    <?php 
    //			$count = Count($this->paginator);		
    //			if($count != '0'){ 
    		 	$slno = ($this->paginator->getCurrentPageNumber() * 10) - 9;
    			$i = 0;
    			$prevName = '';
    			$prevPin  = '';
    
    			foreach($this->paginator as $coursereportdetails){
    					if($coursereportdetails['pass'] == 1){
    						$modulePassRFail = 'Pass';
    					} else if($coursereportdetails['pass'] == 0 && $coursereportdetails['score'] != '') {
    						$modulePassRFail = 'Fail';
    					} else if($coursereportdetails['pass'] == 0 && $coursereportdetails['score'] == '') {
    						$modulePassRFail = '';
    					}
    					if($coursereportdetails['attempteddate'] == ''){
    						$attemptedDate = '';
    					} else {
    						$attemptedDate = CDHelper::toYMDDate($coursereportdetails['attempteddate']);
    					}
    		if($i != 0){
    			$name = $coursereportdetails['firstname'].$coursereportdetails['surname'];
    			if(!($name == $prevName && $coursereportdetails['pinno'] == $prevPin)) {
    				echo "</div>";
    				$slno++; ?>
    <?php			$j = fmod($slno,'2');
    				if($j != '0') {
    ?>
    				<div class="data-1">
    <?php 			} else { ?>
    				<div class="data-2">
    <?php } ?>
    				<div class="feed-data-slno"><?php echo $slno; ?></div>
    				<div class="feed-data"><?php echo $coursereportdetails['firstname']; ?></div>
    				<div class="feed-data"><?php echo $coursereportdetails['surname']; ?></div>
    				<div class="feed-data"><?php echo $coursereportdetails['modulesattempted']; ?></div>
    				<div class="feed-data"><?php echo $modulePassRFail; ?></div>
    				<div class="feed-data"><?php echo $coursereportdetails['attempt']; ?></div>
    				<div class="feed-data"><?php echo $coursereportdetails['score']; ?></div>
    				<div class="feed-data"><?php echo $attemptedDate; ?></div>
    <?php			$prevName = $coursereportdetails['firstname'] . $coursereportdetails['surname'];
    				$prevPin  = $coursereportdetails['pinno'];
    				
    			} else { ?>
    				<div class="feed-data"><?php echo $modulePassRFail; ?></div>
    				<div class="feed-data"><?php echo $coursereportdetails['attempt']; ?></div>
    				<div class="feed-data"><?php echo $coursereportdetails['score']; ?></div>
    				<div class="feed-data"><?php echo $attemptedDate; ?></div>
    <?php			$prevName = $coursereportdetails['firstname'] . $coursereportdetails['surname'];
    				$prevPin  = $coursereportdetails['pinno'];
    			}
    		} else { ?>
    			<div class="data-1">
    				<div class="feed-data-slno"><?php echo $slno; ?></div>
    				<div class="feed-data"><?php echo $coursereportdetails['firstname']; ?></div>
    				<div class="feed-data"><?php echo $coursereportdetails['surname']; ?></div>
    				<div class="feed-data"><?php echo $coursereportdetails['modulesattempted']; ?></div>
    				<div class="feed-data"><?php echo $modulePassRFail; ?></div>
    				<div class="feed-data"><?php echo $coursereportdetails['attempt']; ?></div>
    				<div class="feed-data"><?php echo $coursereportdetails['score']; ?></div>
    				<div class="feed-data"><?php echo $attemptedDate; ?></div>
    <?php			$prevName = $coursereportdetails['firstname'] . $coursereportdetails['surname'];
    				$prevPin  = $coursereportdetails['pinno'];
    		}
    		$i++;
     } ?>
    	
    				
    					<div align="right" class="td resreps-8-151CR"><?php if($count != '0'){ echo $this->paginator; }?></div>
    	  </td>
        </tr>
    			<?php } else { ?>
    			<br></br><br></br><br></br><br></br><br></br>
    				<div align="center"><font color="red" size="2"><?php echo RECORDS_NOT_FOUND; ?></font></div>
    				<br></br><br></br><br></br>
    				<?php } ?>			
      </table>
    </div>
    
    			<!--Main div Ends-->
    		</form>
    	</body>
    </html>
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    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:
    Code:
    // prevents errors when directly calling console & console.log()
    if (typeof console === "undefined" || null === console) {
        console = {
            log: function() {}
        }
    }

    Comment

    Working...