View Full Version : Localstorage ID problem.

11-04-2012, 06:40 PM
It looks like this is not working:


<div id="zaal3"style="position: relative; width: 450px; height: 300px; border: 1px solid black" id="allseats"/>


window.onload = function() {
if(window.localStorage && window.localStorage.seats) {
var theArray = JSON.parse(window.localStorage.seats);
var allestoelen = document.getElementById('allseats').getElementsByTagName('div');
for(i=0; i<allestoelen.length; i++) {
if(theArray[i]===1) allestoelen[i].className="blocked";

function storeIt() {
var allestoelen = document.getElementById('allseats').getElementsByTagName('div');
var theArray = [];
for(i=0; i<allestoelen.length; i++) {
if(allestoelen[i].className == "zwart") {
} else {
var jsonArray = JSON.stringify(theArray);
window.localStorage.seats = jsonArray;
return false;

Someone told me having 2 id's won't work (Id zaal3 & Id allseats in 1 line).
I tried changing 'allseats' in JS to 'zaal3' but it dont seem to be working. What am i doing wrong?

11-04-2012, 09:36 PM
Yo can't give one element two ids. Also that div is self closing which means that it can't contain any other divs for the getElementsBytagName to find.

11-04-2012, 09:44 PM
I give up lol

11-05-2012, 01:34 PM
/*ID's are single use and are only applied to one element

They are used to identify a single element*/

//Classes can be used more than once.

<div class="soso poso">

soso class 1

poso class 2

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum