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);