sam.wiltshire
Posts: 0
Joined: Thu Mar 01, 2012 11:33 pm

Adding multiple items (from checkboxes) to a database array

Hey Katya,

I have shared the app.

If you test the app in the browser, then take the following steps:
ol
liEnter in any letter & a password as an email and password, then click 'register', not 'login'./li
liSelect any one or two of the NBA teams that are listed there, then click 'register'/li
liAt this point I would like the values of the selected items be added into an array named 'userTeams', however, it is not doing so. I also set up an alert to list the items but this (only now) isn't working either./li
/ol

I hope this is what you need.

Thanks!

Sam

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Adding multiple items (from checkboxes) to a database array

Hi Sam,

Try to change the order of "Action" events, so that the "Run JavaScript" was in first place
Image

sam.wiltshire
Posts: 0
Joined: Thu Mar 01, 2012 11:33 pm

Adding multiple items (from checkboxes) to a database array

Hey Illya,

I've tried that however it doesn't seem to help.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Adding multiple items (from checkboxes) to a database array

Hi Sam,

We are able to open your shared app.

Please open Chrome Developer Tools (F12), Console tab and send me a screen shot of error.

sam.wiltshire
Posts: 0
Joined: Thu Mar 01, 2012 11:33 pm

Adding multiple items (from checkboxes) to a database array

Hi Katya

Thanks for your assistance. Here is what I have in my Chrome Developer Tools.

Image

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Adding multiple items (from checkboxes) to a database array

Hi Sam,

There is an incorrect value stored in localStorage variable. There should be an array in JSON format, but this error appears due to incorrect format.

Clean localStorage variable that name is sent to "save" function. You can do this in Chrome Developer tools:
Image

sam.wiltshire
Posts: 0
Joined: Thu Mar 01, 2012 11:33 pm

Adding multiple items (from checkboxes) to a database array

Hi Katya

Thanks for that - I've now managed to get the array successfully storing as a localStorage variable.

Now the second part of the task - getting the localStorage variable to save to the database. I have followed this tutorial (http://docs.tiggzi.com/tutorials/buil...) as much as I can for my app and it seems that as I am sending an array to the database it doesn't seem to work.

I have this mapping setup on the create service (actually on the update service event also):

Image

FYI, userTeams contains my array that I wish to upload.

I am then finding that I am getting two different errors - a 500 & a 405:

Image

Image

Thanks for your help so far!

sam.wiltshire
Posts: 0
Joined: Thu Mar 01, 2012 11:33 pm

Adding multiple items (from checkboxes) to a database array

Also, not sure if I clarified - the 'teams' field in my database is listed as an array and that is the field that I would like to get updated.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Adding multiple items (from checkboxes) to a database array

Hi Sam,

To save localStorage variable "userTeams" in Database you should convert string value to an array. In front of Request parameter "teams" click "Add JS" and paste the following code:
codereturn JSON.parse(value);/code

Return to “Issues”