Skip to content

Instantly share code, notes, and snippets.

@stianeklund
Last active November 19, 2015 19:50
Show Gist options
  • Save stianeklund/de4935c2bca2e88828cd to your computer and use it in GitHub Desktop.
Save stianeklund/de4935c2bca2e88828cd to your computer and use it in GitHub Desktop.
Trying to write to JSON
var data = {
"customers": [{
"firstName": "John",
"lastName": "Smith",
"age": 25,
"address": {
"streetAddress": "20 Broadway St",
"city": "New York",
"state": "NY",
"postalCode": "10021",
"phoneNumber": "212 555-1234"
}
}]
};
var customersrepo = JSON.parse(data);
function returnOrder() {
for (i = 0; i < 4; i++) {
if (orderForm.orderCheckbox[i].checked) {
confirm("Hi " + orderForm.firstName.value + " " +
orderForm.lastName.value + ", you've ordered " +
orderForm.orderCheckbox[i].value);
customersrepo.customers[0].firstName = orderForm.firstName.value;
customersrepo.customers[0].lastName = orderForm.lasvName.value;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment