Page 1 of 2
How do I populate a database collection with values selected by user in a Select component
Posted: Thu Jun 11, 2015 3:50 pm
by Mac Strait
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.
How do I populate a database collection with values selected by user in a Select component
Posted: Thu Jun 11, 2015 3:59 pm
by Mac Strait
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.
How do I populate a database collection with values selected by user in a Select component
Posted: Thu Jun 11, 2015 7:39 pm
by Alena Prykhodko
Hello,
You will need to use service to populate database with values as well
https://devcenter.appery.io/documenta...
How do I populate a database collection with values selected by user in a Select component
Posted: Thu Jun 11, 2015 7:57 pm
by Mac Strait
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.
How do I populate a database collection with values selected by user in a Select component
Posted: Fri Jun 12, 2015 1:00 pm
by Serhii Kulibaba
Hello Mac,
Please remove mapping arrow from select component and get it's value with JS below:
var value = Apperyio("Select_Stake").val();
How do I populate a database collection with values selected by user in a Select component
Posted: Fri Jun 12, 2015 3:46 pm
by Mac Strait
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
How do I populate a database collection with values selected by user in a Select component
Posted: Sat Jun 13, 2015 10:08 pm
by Alena Prykhodko
Mac,
Could you please clarify do you need further assistance here?
How do I populate a database collection with values selected by user in a Select component
Posted: Sun Jun 14, 2015 12:34 pm
by Mac Strait
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.
How do I populate a database collection with values selected by user in a Select component
Posted: Mon Jun 15, 2015 6:38 pm
by Serhii Kulibaba
Please use simple JS:
return Apperyio("Select_Stake").val();
How do I populate a database collection with values selected by user in a Select component
Posted: Tue Jun 16, 2015 2:33 pm
by Mac Strait
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.