Mac Strait
Posts: 0
Joined: Thu May 07, 2015 5:03 pm

How do I populate a database collection with values selected by user in a Select component

Hi,

I have two select components on my page. The select list is populated from the database using REST service, so the user can select an item using the select UI component. This is done by invoking the REST service on page load and works fine.

I then have a button on the page which the user presses. I would like onclick to populate the database with the users selections from the SELECT UI component.

Mac Strait
Posts: 0
Joined: Thu May 07, 2015 5:03 pm

How do I populate a database collection with values selected by user in a Select component

To try and do this I used a before send mapping on the onclick event. The mapping maps the value of the list item to the item in the database, this is a before send mapping.

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

How do I populate a database collection with values selected by user in a Select component

Hello,

You will need to use service to populate database with values as well
https://devcenter.appery.io/documenta...

Mac Strait
Posts: 0
Joined: Thu May 07, 2015 5:03 pm

How do I populate a database collection with values selected by user in a Select component

Hi, I am using a create service to try and get the users selection into the database. It might help if I attach a couple of pictures. I attach two screenshots. One shows the mapping that is used for the list REST service to populate the list in the drop down from the database. The user then selects from the list. This works fine and is triggered on page load.

The second screenshot shows the attempted mapping from the create service which is triggered as an onclick event. Image Image

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

How do I populate a database collection with values selected by user in a Select component

Hello Mac,

Please remove mapping arrow from select component and get it's value with JS below:
var value = Apperyio("Select_Stake").val();

Mac Strait
Posts: 0
Joined: Thu May 07, 2015 5:03 pm

How do I populate a database collection with values selected by user in a Select component

I deleted the mapping arrow and used the js in the mapping action editor. It does not seem to return anything. I will have a play with using js for some of the other ui components to get values

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

How do I populate a database collection with values selected by user in a Select component

Mac,

Could you please clarify do you need further assistance here?

Mac Strait
Posts: 0
Joined: Thu May 07, 2015 5:03 pm

How do I populate a database collection with values selected by user in a Select component

Hi,

Thanks for asking, I do require more assistance. I am struggling to get the value selected by the user in a select UI component back to the database. I used the Javascript suggested by Sergiy to populate the return value, but I must be doing something wrong as nothing is returned.

I just deleted the mapping arrow and added the javascript as suggested. I tried it with a return statement but that just returns the string "Value" into the database. The service is still invoked on a "Onclick" event.

I have attached the image of the mapping. Image

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

How do I populate a database collection with values selected by user in a Select component

Please use simple JS:

return Apperyio("Select_Stake").val();

Mac Strait
Posts: 0
Joined: Thu May 07, 2015 5:03 pm

How do I populate a database collection with values selected by user in a Select component

Hi,

I used the above JS and it does not populate the database with the value selected by the user from the selection box. I get the string "Value" in the database. This looks like the JS is taking the default value of the Label for the selection UI item.

I need it to take the value of the selection box after the user has selected it from the select UI component.

Return to “Issues”