By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,341 Members | 1,681 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,341 IT Pros & Developers. It's quick & easy.

hidden data - best practice, best way, suggestions

P: n/a
I have two sets of text strings. They are related to each other and
are not proprietary. X group contains about 2000 short, one to three
word, strings. Y contains about 50. These two groups supply the
option items in two select boxes. Box Y scopes the items allowed in
select box X. As selections in Y are made, optional items in X
change.

Ive never hidden so much data before and wondered if there is a best
way to do this. I intended to create a string, comma delimited, of X
Y pairs, and when the information is required for use, split it and
either consider the data immediately or park it in an array for a next
process step.

Call backs to the server have been considered and rejected. The data
must accompany the page.

Thanks.
Sep 10 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Wed, 10 Sep 2008 12:29:49 -0700, oldyork90 wrote:
I have two sets of text strings. They are related to each other and are
not proprietary. X group contains about 2000 short, one to three word,
strings. Y contains about 50. These two groups supply the option items
in two select boxes. Box Y scopes the items allowed in select box X.
As selections in Y are made, optional items in X change.

I’ve never hidden so much data before and wondered if there is a best
way to do this. I intended to create a string, comma delimited, of X Y
pairs, and when the information is required for use, split it and either
consider the data immediately or park it in an array for a next process
step.

Call backs to the server have been considered and rejected. The data
must accompany the page.

Thanks.
From your description, look at storing your data in an object, rather
than multiple arrays. (Objects, in Javascript, are very similar
associative arrays in other languages, though there are some difference.)

/* Untested syntax */

var myObject = {
"car" : ["ford", "chevy", "vw"],
"boat" : ["rowboat"]
}

To access the members, you would do something like:
for (key in myObject) {
if myObject.hasOwnProperty(key) {
alert(key);
}
}

Will alert "car" and "boat"

To look at the options for car and boat, I would do:
key = "car";
var myArray = myObject[key];

for (var i = 0; i < myArray.length; i++) {
alert(myArray[i]);
}

If this data is fairly static, make it an .js file and script it in to
your page to take advantage of caching.
Sep 10 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.