I'm building a webpage interface for an RV park database system.
Currently I'm working on a webpage that will allow a 'agent' to see what sites are availible. Using ASP and javascript.
I've having trouble figuring out the currect scripting for only returning the site numbers that will be availible for a certain time slot.
I have a function (Code below), which querys the database and returns all the important data from table 'Visit'. The function then trys to select just the correct data out of the data from the database, and return it in a usable form.
For example: Customer A is staying from Jan 4th to Jan 9th.
Customer B's schedule has the possiblity of 4 positions.
[ol][li]Before A's scheduled time(ex.1st-3rd),[/li]
[li]Overlapping the start of A's scheduled time(ex.2nd-5th),[/li]
[li]Overlapping the end of A's Scheduled time(ex.8th-12th),[/li]
[li]After A's scheduled time(ex.12th-15th)[/li][/ol]
Obviously, we don't want this function returning any sites that match 2 or 3. Below are the functions.
======================CODE=======================
=========END of code=========
The startDate and endDate fields are 'date/time' fields.
I can get data from the database fine, so thats not a problem. Also, the values that are passed into 'GetSitesBydate' are Date() objects.The SQL works fine.
Basically, the code is not performing as desired. It dosn't loop enough times somewhere (Yea, I wrote the code
), and I'm having trouble finding whats wrong.
If anyone has any suggustions/hints/tips, By all means, let me know!
Thanx in advance.
-Suthern
Currently I'm working on a webpage that will allow a 'agent' to see what sites are availible. Using ASP and javascript.
I've having trouble figuring out the currect scripting for only returning the site numbers that will be availible for a certain time slot.
I have a function (Code below), which querys the database and returns all the important data from table 'Visit'. The function then trys to select just the correct data out of the data from the database, and return it in a usable form.
For example: Customer A is staying from Jan 4th to Jan 9th.
Customer B's schedule has the possiblity of 4 positions.
[ol][li]Before A's scheduled time(ex.1st-3rd),[/li]
[li]Overlapping the start of A's scheduled time(ex.2nd-5th),[/li]
[li]Overlapping the end of A's Scheduled time(ex.8th-12th),[/li]
[li]After A's scheduled time(ex.12th-15th)[/li][/ol]
Obviously, we don't want this function returning any sites that match 2 or 3. Below are the functions.
======================CODE=======================
Code:
function printArrayOptions(name,options) {
Response.write("<select width='3' name="+name+">");
for (i=1;i<options.length;i++) {
if (options[i]==true) {
Response.write(" <option value=\""+i+"\">");
Response.write(i);
Response.write(" </option>\n");
}
}
Response.write("</select>");
}
function GetSitesByDate(StartDate,EndDate)
{
var conn = makeConnection;
var sites = new Array();
var selSQL = "Select SiteID,StartDate,EndDate from Visit";
var ss = executeSQL(selSQL);
var ri=0, i=0;
var ss2 = new Object();
while(!ss.eof){ //Per line in results from visit table
ss2.SiteID = new String(ss("SiteID"));
ss2.StartDate = new String(ss("StartDate"));
ss2.EndDate = new String(ss("EndDate"));
for (test=StartDate;test<=EndDate;test.setDate(test.getDate+1)) { //Testing each Day the custoemr is staying
//sites[test+100] = true;
sites[ri+75] = true; //debugging
if (test>ss2.StartDate&&test<ss2.EndDate){
sites[ss(0)] = false;
} else {
sites[ss(0)] = true;
}
sites[ri+30] = true; //debugging
ri++;
}
ss.movenext();
sites[ss2.SiteID + 100] = true; //debugging
i++;
};
var max=40;
sites[48] = true;
//sites = [0,1,1,0,1,0,1,0,1,1,1,1,0,1,1,1,0,0,0,1,0,1]; //testing array
ss.close();
return sites;
}
=====Code for printing=======
<% var sites = GetSitesByDate(startDate,endDate);
printArrayOptions("SiteID",sites); %>
The startDate and endDate fields are 'date/time' fields.
I can get data from the database fine, so thats not a problem. Also, the values that are passed into 'GetSitesBydate' are Date() objects.The SQL works fine.
Basically, the code is not performing as desired. It dosn't loop enough times somewhere (Yea, I wrote the code

If anyone has any suggustions/hints/tips, By all means, let me know!
Thanx in advance.
-Suthern