hidden data - best practice, best way, suggestions

O

oldyork90

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.
 
J

Jeremy J Starcher

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

If this data is fairly static, make it an .js file and script it in to
your page to take advantage of caching.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top