J
julie.siebel
I've been wrestling with a really complex page. All the data is drawn
down via SQL, the page is built via VBScript, and then controlled
through javascript.
It's a page for a travel company that shows all the properties, weeks
available, pricing, etc. for a particular area of Europe. The data
varies widely depending on the region; at times there will be 50
properties, and at other times only a half dozen.
The cross referencing of pricing information, maximum guests, etc. per
property and per date had been driving me crazy, and was requiring
what felt like 17 million arrays.
Javascript isn't my specialty, so please pardon my ignorance. I'd
never heard of using an object instead of an array, and ran across it
in a web page today. It is absolutely *perfect* for what I am doing,
but I'm concerned - it seems too easy. I'm trying to figure out what
the pitfalls are.
Is it slow? Is it incompatible with a bunch of browsers? lol - it just
seems too easy after struggling with this for a couple of days. And if
it isn't slow, is it any faster than an array search? This page has
TONS of arrays, and I'm using vbscript to actually build them into the
onclick call for each date on the page. If using Object() is an
acceptable method of doing things, it could really clean up my links.
Here is the kind of thing I am doing:
var ratetable = new Object();
ratetable["r1123"] = [800,400,300,200,0,0,0,0];
ratetable["r6543"] = [-50, -100, -150, 0, 0, 0, 0, 0];
ratetable["r2342"] = [50,50,50,50,25,25,25,25]
rvalue="r6543";
passengers=3;
alert(ratetable[rvalue][passengers-1])
In reality, clicking on a property calls a javascript function which
assigns the rvalue, and adjusts the prices for the tour based on the
number of passengers, the date, and the property selected. I also have
tables that show which properties are available by date, which dates
are available per property, lol - it's a mess. This object thingy if
it is OK to use would be SOOO great.
What am I missing here?
Thanks,
Julie
down via SQL, the page is built via VBScript, and then controlled
through javascript.
It's a page for a travel company that shows all the properties, weeks
available, pricing, etc. for a particular area of Europe. The data
varies widely depending on the region; at times there will be 50
properties, and at other times only a half dozen.
The cross referencing of pricing information, maximum guests, etc. per
property and per date had been driving me crazy, and was requiring
what felt like 17 million arrays.
Javascript isn't my specialty, so please pardon my ignorance. I'd
never heard of using an object instead of an array, and ran across it
in a web page today. It is absolutely *perfect* for what I am doing,
but I'm concerned - it seems too easy. I'm trying to figure out what
the pitfalls are.
Is it slow? Is it incompatible with a bunch of browsers? lol - it just
seems too easy after struggling with this for a couple of days. And if
it isn't slow, is it any faster than an array search? This page has
TONS of arrays, and I'm using vbscript to actually build them into the
onclick call for each date on the page. If using Object() is an
acceptable method of doing things, it could really clean up my links.
Here is the kind of thing I am doing:
var ratetable = new Object();
ratetable["r1123"] = [800,400,300,200,0,0,0,0];
ratetable["r6543"] = [-50, -100, -150, 0, 0, 0, 0, 0];
ratetable["r2342"] = [50,50,50,50,25,25,25,25]
rvalue="r6543";
passengers=3;
alert(ratetable[rvalue][passengers-1])
In reality, clicking on a property calls a javascript function which
assigns the rvalue, and adjusts the prices for the tour based on the
number of passengers, the date, and the property selected. I also have
tables that show which properties are available by date, which dates
are available per property, lol - it's a mess. This object thingy if
it is OK to use would be SOOO great.
What am I missing here?
Thanks,
Julie