Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-01-2012, 06:39 PM   PM User | #1
nest9
New to the CF scene

 
Join Date: Dec 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
nest9 is an unknown quantity at this point
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 08:14 PM..
nest9 is offline   Reply With Quote
Old 12-01-2012, 07:21 PM   PM User | #2
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
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
AndrewGSW is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:09 AM.


Advertisement
Log in to turn off these ads.