John Herdean
Posts: 0
Joined: Tue May 14, 2013 3:56 am

how to select more than one from a select menu?

outstanding issue 2

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

how to select more than one from a select menu?

Hi John,

[quote:]I need to retrieve, what is the API to do that?[/quote]There is no such API. Run the following JS code: codeAppery("mobileselectmenuName").val().length/code
[quote:]I cant seem to set the value of a localStorage into the selected menu.[/quote]To do this you would need to use JavaScript. Go through the List of items and mark them in list.

How do you save checked items in localStorage?

John Herdean
Posts: 0
Joined: Tue May 14, 2013 3:56 am

how to select more than one from a select menu?

ok well for example i tried to alert me the value and doesnt do anything like this:

----------------------------------------------------

var input = Appery("mobileselectmenuName").val().length;
alert (input.val());

--------------------------------------------------

Firebug says: 'TypeError: input.val is not a function'

John Herdean
Posts: 0
Joined: Tue May 14, 2013 3:56 am

how to select more than one from a select menu?

storing into localstorage works:

---------------------------------------------------

var a = Appery("interests_music").val().length;
localStorage.setItem('total_music_interests', a)

--------------------------------------------------------------

but not alerting the value of the component

John Herdean
Posts: 0
Joined: Tue May 14, 2013 3:56 am

how to select more than one from a select menu?

how about outstanding issue 2? how do i make that work?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

how to select more than one from a select menu?

John,

codevar input = Appery("mobileselectmenuName").val().length/code
This code returns a number. A number doesn't have val() method. This code returns length of a string or an array.

John Herdean
Posts: 0
Joined: Tue May 14, 2013 3:56 am

how to select more than one from a select menu?

how about outstanding issue 2? I havent got a response yet on that?

John Herdean
Posts: 0
Joined: Tue May 14, 2013 3:56 am

how to select more than one from a select menu?

uhmm i even tried this JS and doesnt do anything:

------------------------------------------------------------------------------------------------

Appery( "mobileselectmenuName" ).val( localStorage.getItem( "interest_music" ) );

------------------------------------------------------------------------------------------------

so, how do i populate the select menu with the items in local storage? to clarify, a predefined list is already there, i just need to have the appropiate items checked according to what is in local storage (in this example)??

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

how to select more than one from a select menu?

Hello! To save to localStorage variable all checked values use:
codelocalStorage.setItem("interests_music", JSON.stringify(Appery("interests_music").val()));/code

to retrieve values from localStorage variable code
var selectedValues;
try {
selectedValues = JSON.parse(localStorage.getItem("interests_music"));
if ({}.toString.call(selectedValues) !== "[object Array]") {
selectedValues = [];
}
} catch ( e ) {
selectedValues = [];
}

Appery("interests_music").find("option").each(function() {
var $this = $(this)
if (selectedValues.indexOf($this.prop("value")) != -1) {
$this.prop("selected", true);
} else {
$this.prop("selected", false);
}
})
Appery("interests_music").selectmenu("refresh");/code
where interests_music - name of select with multiple selection enabled

John Herdean
Posts: 0
Joined: Tue May 14, 2013 3:56 am

how to select more than one from a select menu?

thank you, this is exactly what i was looking for :)

Return to “Issues”