I wish to save the values from the input boxes in a dynamically created form but I´m having some trouble constructing the object that is to put into the IndexedDB objestStore.
I need something like this:
[{"name": "box1 value", "last name": "box2 value", "age": "box3 value"},{"name": "box4 value", "last name": "box5 value", "age": "box6 value"}]
propriety names have to stay the same (equal to the indexes in the objectStore), only the values change.
The code:
var rows = document.getElementById('myTable').getElementsByTagName('tbody')[0].getElementsByTagName('tr');
for (i = 0; i < rows.length; i++) {
var boxes = rows.getElementsByClassName('input');
for (i = 0; i < boxes.length; i++) {
objectStore.put('values');
};
};
I’m trying JSON.stringify(); but I’m not getting it to work…
Any ideas?
I think the best thing to do is:
– Give all input fields for the same property the same name attribute
– retrieve for each row the values of these input fields
– Construct the object
– save the object.
In pseudo code: