Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: GRID Undefined

  1. #1
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    GRID Undefined

    I have spent a couple of days not customizing a script I purchased to fit the needs of my website. I have some expereince with coding but not enough to figure out where a couple of my errors are coming from. For instance, when I debug a page on my website, it links me to the following error: 'GRIDW' is undefined The line in question, it highlighted below near the end of the page. Thanks for any feedback and help. I have two other (related/unlrealated) issues that I will post separately.
    Thanks in advance for your time.


    Code:
    /*
    
     	['<?php echo $row_recZones1['name']; ?>', <?php echo $row_recZones1['x1']; ?>, <?php echo $row_recZones1['y1']; ?>, 
    
    	<?php echo $row_recZones1['x2']+1; ?>, <?php echo $row_recZones1['y2']+1; ?> ,<?php echo $row_recZones1['price']; ?>,
    
    	<?php echo $row_recZones1['max_buy']; ?>],
    
    */
    
    
    
    function Ovl(oArea, z) {
    
    	var area = 0;
    
    	if (z[1] < oArea.x2 && z[2] < oArea.y2 && oArea.x1 < z[3]  && oArea.y1 < z[4]) {	
    
    		area = Math.min(oArea.x2 - z[1], z[3] - oArea.x1, oArea.w, z[3] - z[1]) *
    
    						Math.min(z[4] - oArea.y1, oArea.y2 - z[2], oArea.h, z[4] - z[2]);  
    
    	}	
    
    	
    
    	return area;
    
    }
    
    
    
    function FindOffendingZone(oArea, zones) {
    
    	for (i in zones) {
    
    		var z = zones[i];
    
    		var area = Ovl(oArea, z);
    
    		if (area > z[6]) {
    
    			return z[0] + " only accepts " + z[6] + " blocks maximum";
    
    		}
    
    	}
    
    	
    
    	return false;
    
    }
    
    
    
    function CalcZonalPrices(oArea, zones, pxprice) {
    
    	var area = oArea.w * oArea.h;
    
    	var amt = 0;
    
    	var totalpixels = GRIDW*GRIDH;	
    
                 for (i in zones) {
    
    		var z = zones[i];
    
    		var ova = Ovl(oArea, z);
    
    		amt += ova * totalpixels * z[5];
    
    		area -= ova;			
    
    	}
    
    	amt += area * pxprice * totalpixels;	
    
    	return amt.toFixed(2);
    Last edited by nest9; 12-01-2012 at 09:14 PM.

  • #2
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    Yes, GRIDW is undefined according to the code you have shown. You'll need to show the code that defines it and ensure that this code runs before the code fragment you have shown.

    Also, enclose your code in CODE tags by clicking the hash sign # when creating your post: select the code and press #.
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •