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