Page 1 of 1

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

Posted: Tue Apr 21, 2015 11:14 pm
by Alan Wong

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


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

Posted: Wed Apr 22, 2015 8:52 am
by Alena Prykhodko

Hello Alan,

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


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

Posted: Thu Apr 23, 2015 1:23 am
by Alan Wong

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.


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

Posted: Thu Apr 23, 2015 1:27 am
by Alan Wong

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


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

Posted: Mon Apr 27, 2015 11:48 pm
by Yurii Orishchuk

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.