hidden data - best practice, best way, suggestions

Discussion in 'Javascript' started by oldyork90, Sep 10, 2008.

  1. oldyork90

    oldyork90 Guest

    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.
     
    oldyork90, Sep 10, 2008
    #1
    1. Advertising

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

    If this data is fairly static, make it an .js file and script it in to
    your page to take advantage of caching.
     
    Jeremy J Starcher, Sep 10, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UGV0ZXI=?=

    Deliver video files - best way of practice?

    =?Utf-8?B?UGV0ZXI=?=, Sep 26, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    392
    =?Utf-8?B?UGV0ZXI=?=
    Sep 26, 2007
  2. Rick
    Replies:
    3
    Views:
    8,592
    Alexey Smirnov
    Apr 13, 2010
  3. Antoine Pitrou
    Replies:
    0
    Views:
    450
    Antoine Pitrou
    Jul 27, 2010
  4. SolarCanine
    Replies:
    2
    Views:
    342
    SolarCanine
    Sep 20, 2005
  5. Justin C
    Replies:
    1
    Views:
    149
    ccc31807
    Nov 11, 2013
Loading...

Share This Page