Ellen Schlechter
Posts: 0
Joined: Sun Aug 31, 2014 3:28 am

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

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?

Ihor Didevych
Posts: 0
Joined: Wed Nov 19, 2014 7:55 pm

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

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.

Ellen Schlechter
Posts: 0
Joined: Sun Aug 31, 2014 3:28 am

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

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?

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

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

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.

Ellen Schlechter
Posts: 0
Joined: Sun Aug 31, 2014 3:28 am

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

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.

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

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

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.

Ellen Schlechter
Posts: 0
Joined: Sun Aug 31, 2014 3:28 am

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

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

Return to “Issues”