Josette
Posts: 0
Joined: Mon Jun 08, 2015 10:59 pm

How to select items in select menu with Javascript

I would like to use Javascript to automatically select the items in a select menu after they have been loaded. I have tried the following code, but it did not work.

$.each(data, function(index, value) {
Apperyio("messsage_select option[value = " + value.member._id + "]").attr("selected", true);
Apperyio("message_select").selectmenu().selectmenu("refresh", true);
});

Your help will be greatly appreciated.
Thank you.

Pavel Zarudniy
Posts: 0
Joined: Mon Jul 06, 2015 8:56 am

How to select items in select menu with Javascript

Hi Josette,
You simply need to change value of selectbox with method val()

Josette
Posts: 0
Joined: Mon Jun 08, 2015 10:59 pm

How to select items in select menu with Javascript

Can you give an example since your answer is vague. I need to change the attribute to selected via JavaScript for all the items and not the value of the select menu.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

How to select items in select menu with Javascript

Hi Josette -

You can search for examples on our forum: https://getsatisfaction.com/apperyio/...

Return to “Issues”