Page 1 of 3

Have default value of a select menu come from the database have have other options listed.

Posted: Thu Jan 08, 2015 2:07 pm
by Ellen Schlechter

When a user chooses a certain option, I want that option to be the default option in another select menu...the first one displayed.

Then I want the user to be able to update it so I want other options to be there too. I have two different cases. One is where the user creates them and saves then they have their options specific to them. The other case is the same for everyone. They will have 5 options to pick from. I want the one that they originally picked to be the first one there.

Any ideas on how to do this?


Have default value of a select menu come from the database have have other options listed.

Posted: Fri Jan 09, 2015 9:55 am
by Ihor Didevych

Hello Ellen,

When a user chooses a certain option, I want that option to be the default option in another select menu...the first one displayed.
1) You should use mapping with LSV. Save selected value in LSV. Then set mapping for this select menu with value from LSV on the page with second select menu .
Important to have same labels for values in both select menus

I want the one that they originally picked to be the first one there.
2) Save first selected value in DB. Then each time on page show event prepopulate select menu from DB for that user.


Have default value of a select menu come from the database have have other options listed.

Posted: Sun Jan 11, 2015 7:50 pm
by Ellen Schlechter

1) I'm sorry, I wasn't clear. A user fills out a form. Two of the fields are select menus and the values are saved in the database. So LSV won't work.

The point of this app is for the users to fill out the for many, many times each with different specifications because they are keeping records for calves.

Case A:
I want a select menu to display the option that was saved when the user created the calf. Then I want there to be other options that they have created and saved in the database. I have populated a select menu with the list service before, but how do I get a specific one to be the first displayed?

Case B:
This is similar except the menu is just gender. When they create a calf, they will save its gender, then I want in a select menu for them to be able to change the gender in case there was an error. The options will be preset by me in the options menu. So how do I get the value that was saved in the database to be displayed first?


Have default value of a select menu come from the database have have other options listed.

Posted: Wed Jan 14, 2015 5:53 am
by Yurii Orishchuk

Hi Ellen,

You can use following JS code to set certain value in select component.

pre

//You have to change "mobileselectmenu_10" with your select component name.
var yourSelect = Appery("mobileselectmenu_10");
yourSelect.val("default");
yourSelect.selectmenu('refresh', true);

/pre

Note: you need to set current value in select after this select has been populated by service mapping. For example on the "success" event handler.

Regards.


Have default value of a select menu come from the database have have other options listed.

Posted: Mon Jan 19, 2015 4:51 am
by Ellen Schlechter

I thought this was working but it still doesn't list the actual value in the database first so that it is visible. I need it to have the database value first, then the other options.


Have default value of a select menu come from the database have have other options listed.

Posted: Tue Jan 20, 2015 1:19 pm
by Ellen Schlechter

?


Have default value of a select menu come from the database have have other options listed.

Posted: Wed Jan 21, 2015 1:28 am
by Yurii Orishchuk

Hi Ellen,

Given code should work to set certain value in the select.

Please check whether you run it correctly.

Also FYI: you should run this code only when select component already populated.

Regards.


Have default value of a select menu come from the database have have other options listed.

Posted: Wed Jan 21, 2015 3:10 am
by Ellen Schlechter

I run it upon the success of the service that I use to populate the menu. That is how it is supposed to be right???

Image


Have default value of a select menu come from the database have have other options listed.

Posted: Fri Jan 23, 2015 5:55 am
by Ellen Schlechter

????


Have default value of a select menu come from the database have have other options listed.

Posted: Tue Jan 27, 2015 2:48 am
by Ellen Schlechter

?