Page 1 of 1

How to select items in select menu with Javascript

Posted: Fri Jul 10, 2015 2:00 am
by Josette

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.


How to select items in select menu with Javascript

Posted: Fri Jul 10, 2015 12:13 pm
by Pavel Zarudniy

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


How to select items in select menu with Javascript

Posted: Fri Jul 10, 2015 12:46 pm
by Josette

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.


How to select items in select menu with Javascript

Posted: Fri Jul 10, 2015 9:03 pm
by Illya Stepanov

Hi Josette -

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