Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > store information in a tag?

Reply
Thread Tools

store information in a tag?

 
 
Kourosh
Guest
Posts: n/a
 
      06-09-2006
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

 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      06-09-2006
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.
 
Reply With Quote
 
 
 
 
Robert
Guest
Posts: n/a
 
      06-09-2006
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.
 
Reply With Quote
 
Kourosh
Guest
Posts: n/a
 
      06-09-2006

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?

 
Reply With Quote
 
Kourosh
Guest
Posts: n/a
 
      06-09-2006

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

 
Reply With Quote
 
Robert
Guest
Posts: n/a
 
      06-12-2006
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");
 
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
Where does ASP.NET Membership store the information? Nathan Sokalski ASP .Net 1 07-18-2008 03:37 PM
Thunderbird won't store my account information RicBrazil Firefox 7 01-13-2007 04:52 PM
to store or not to store an image =?Utf-8?B?UnVkeQ==?= ASP .Net 6 03-30-2005 05:51 AM
where does JNDI store context binding information Cheok Yan Cheng Java 1 04-14-2004 11:20 PM
Does IE really store all surfing information? Kheehua Computer Support 4 08-21-2003 01:55 AM



Advertisments