Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > hidden data - best practice, best way, suggestions

Reply
Thread Tools

hidden data - best practice, best way, suggestions

 
 
oldyork90
Guest
Posts: n/a
 
      09-10-2008
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.
 
Reply With Quote
 
 
 
 
Jeremy J Starcher
Guest
Posts: n/a
 
      09-10-2008
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate Hidden field on post back and retrieve value from Hidden Field Rick ASP .Net 3 04-13-2010 05:38 PM
Win 7 folders hidden despite 'show hidden' checked Boppy NZ Computing 10 01-23-2010 02:56 AM
suggestions re: data recovery services for Peachtree data? Jacques Clouseau Computer Support 4 04-09-2008 01:02 PM
How would I discover the text in a block element hidden by overflow:hidden style being set? SolarCanine Javascript 2 09-20-2005 06:27 PM
Help esk Suggestions - Best Practices, Tool, ideas, suggestions, etc JohnNews Computer Support 3 06-23-2003 11:20 PM



Advertisments