I'm working on a form that is saved by HTML5 local storage.

When pressing save:

```
function saveAll(){
  var field1 = document.getElementById('field1').value;
  localStorage.setItem('con_field1',field1);
  var field2 = document.getElementById('field2').value;
  localStorage.setItem('con_field2',field2);
  var field3 = document.getElementById('field3').value;
  localStorage.setItem('con_field3',field3);
  var field4 = document.getElementById('field4').value;
  localStorage.setItem('con_field4',field4);
  var field5 = document.getElementById('field5').value;
  localStorage.setItem('con_field5',field5);
  var field6 = document.getElementById('field6').value;
  localStorage.setItem('con_field6',field6);
}

```

And when loading the page (fills out the forms):

```
function ShowAll() {
  var field1 = localStorage.getItem('con_field1');
  document.conditioning.field1.value = field1;
  var field2 = localStorage.getItem('con_field2');
  document.conditioning.field2.value = field2;
  var field3 = localStorage.getItem('con_field3');
  document.conditioning.field3.value = field3;
  var field4 = localStorage.getItem('con_field4');
  document.conditioning.field4.value = field4;
  var field5 = localStorage.getItem('con_field5');
  document.conditioning.field5.value = field5;
  var field6 = localStorage.getItem('con_field6');
  document.conditioning.field6.value = field6;
}

```

This all works fine, but I want to re-write this in a more fancy and efficient way. I was thinking of something like this:

```
function ShowAll() {
  var field = [];
  for (i=0; i<6; i++) {
    field[i] = localStorage.getItem(window['con_field' + i]);
    document.purpose.field[i].value = window['con_field' + i]
  }
}

```

But the browser is not enjoying this. Basically I need to create a loop that automatically changes the "field" name in to 'field1, field2, field3' etc. The window thing is working, but I'm just using it wrong.

Anyone has an idea?

Thanks a lot!