Alan Wong
Posts: 0
Joined: Tue Apr 21, 2015 5:06 pm

How to store the value of the input to an array in the database

I have a input on the page. Users can put multiple items separated by ";", eg tomato; potato. Then I want to store them to an array in the database.
How I can do that?
Image

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

How to store the value of the input to an array in the database

Hello Alan,

To add data to database you need to use create service
https://devcenter.appery.io/documenta...

Alan Wong
Posts: 0
Joined: Tue Apr 21, 2015 5:06 pm

How to store the value of the input to an array in the database

This is not very help helpful. I still don't know how to store the array. I expect the answer would be some JS code or something. I don't know.

Alan Wong
Posts: 0
Joined: Tue Apr 21, 2015 5:06 pm

How to store the value of the input to an array in the database

I did use create service. Everything is working except the array. The question is I don't know how to store the array.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

How to store the value of the input to an array in the database

Hi Alan,

Please follow these steps:

  1. Click on JS on needed link in mapping.
    Details: http://prntscr.com/6yyy9e/direct

  2. Populate it with following JS code:

    pre

    var str = value; //"tomato; potato; carrot";
    var jsonArray = '["' + str.replace(/;/gi, '", "') + '"]';
    var arrayObject = JSON.parse(jsonArray);
    return arrayObject;

    /pre

    Regards.

Return to “Issues”