store information in a tag?

Discussion in 'Javascript' started by Kourosh, Jun 9, 2006.

  1. Kourosh

    Kourosh Guest

    I want to store some state infomation for each DIV tag on a page. Which
    property of the DIV tag should I use for this?
    ie I want to iterate through all DIV tags, and associate each with a
    'state' and store that information in the tag
     
    Kourosh, Jun 9, 2006
    #1
    1. Advertising

  2. Kourosh

    Ian Collins Guest

    Kourosh wrote:
    > I want to store some state infomation for each DIV tag on a page. Which
    > property of the DIV tag should I use for this?
    > ie I want to iterate through all DIV tags, and associate each with a
    > 'state' and store that information in the tag
    >

    Why not just add a property 'state' to each div?

    --
    Ian Collins.
     
    Ian Collins, Jun 9, 2006
    #2
    1. Advertising

  3. Kourosh

    Robert Guest

    Kourosh wrote:
    > I want to store some state infomation for each DIV tag on a page. Which
    > property of the DIV tag should I use for this?
    > ie I want to iterate through all DIV tags, and associate each with a
    > 'state' and store that information in the tag
    >


    Have you thought about storing the states in a seperate javascript
    object? Perhaps you can assign id's to the DIV tags that you want to
    store states for and use those id's to map them to states in a seperate
    object.

    Robert.
     
    Robert, Jun 9, 2006
    #3
  4. Kourosh

    Kourosh Guest

    Robert wrote:
    > Kourosh wrote:
    > > I want to store some state infomation for each DIV tag on a page. Which
    > > property of the DIV tag should I use for this?
    > > ie I want to iterate through all DIV tags, and associate each with a
    > > 'state' and store that information in the tag
    > >

    >
    > Have you thought about storing the states in a seperate javascript
    > object? Perhaps you can assign id's to the DIV tags that you want to
    > store states for and use those id's to map them to states in a seperate
    > object.
    >
    > Robert.


    I see. How would i use the IDs to efficiently map to an array of
    states. Is there a hashtable?
     
    Kourosh, Jun 9, 2006
    #4
  5. Kourosh

    Kourosh Guest

    Ian Collins wrote:
    > Kourosh wrote:
    > > I want to store some state infomation for each DIV tag on a page. Which
    > > property of the DIV tag should I use for this?
    > > ie I want to iterate through all DIV tags, and associate each with a
    > > 'state' and store that information in the tag
    > >

    > Why not just add a property 'state' to each div?
    >
    > --
    > Ian Collins.


    Oh hah thanks. I didnt know I could do that :)
     
    Kourosh, Jun 9, 2006
    #5
  6. Kourosh

    Robert Guest

    Kourosh wrote:
    > Robert wrote:
    >
    >>Kourosh wrote:
    >>
    >>>I want to store some state infomation for each DIV tag on a page. Which
    >>>property of the DIV tag should I use for this?
    >>>ie I want to iterate through all DIV tags, and associate each with a
    >>>'state' and store that information in the tag
    >>>

    >>
    >>Have you thought about storing the states in a seperate javascript
    >>object? Perhaps you can assign id's to the DIV tags that you want to
    >>store states for and use those id's to map them to states in a seperate
    >>object.
    >>
    >>Robert.

    >
    >
    > I see. How would i use the IDs to efficiently map to an array of
    > states. Is there a hashtable?
    >


    Each object in javascript works quite similar as a hashtable.
    Take for example this code:

    function StateStorage()
    {
    var map = new Object();

    this.store = function(id, state)
    {
    map[id] = state;
    }

    this.retrieve = function(id)
    {
    return map[id];
    }
    }

    var stateStorage = new StateStorage();
    stateStorage.store(divId, "my state object");
     
    Robert, Jun 12, 2006
    #6
    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?UnVkeQ==?=

    to store or not to store an image

    =?Utf-8?B?UnVkeQ==?=, Mar 29, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    655
    =?Utf-8?B?UnVkeQ==?=
    Mar 30, 2005
  2. Cheok Yan Cheng
    Replies:
    1
    Views:
    1,859
    Chris Smith
    Apr 15, 2004
  3. shruds
    Replies:
    1
    Views:
    871
    John C. Bollinger
    Jan 27, 2006
  4. Nathan Sokalski
    Replies:
    1
    Views:
    474
    sloan
    Jul 18, 2008
  5. Francis Moreau

    Store information in pointers

    Francis Moreau, Apr 28, 2010, in forum: C Programming
    Replies:
    29
    Views:
    928
    bart.c
    Apr 29, 2010
Loading...

Share This Page