Not correct!! The line event[i] is wrong. When i send 'events' to console i get something this - iterating over a numer of variables and adding their values to the JSON object:
Code:
[Object, "141", undefined, "123"]
if i change it to
Code:
events = checks[i].value;
I only see the last item which makes sense
Then i tried
Code:
events += checks[i].value;
And i get
[object Object]141167. // 141 being the first item and 167 second item. But will like to have the object as [141,167] - how can i do that when adding to the object???
Here is some of my code to clear this up a bit
Code:
...
var events = [{}]; // empty JSON object
var checks = dojo.query("input[name=item]");
var length = checks.length;
for(var i=0; i < length; i++){
if(checks[i].checked == true){
events += checks[i].value;
}
}
console.log(events);
I reckon the object Object item that is part of the JSON's values comes from the fact that i declared and empty JSON object from the start.
How can i recitify this- just the right values showing on events?
Thanks
Bookmarks