Page 2 of 5

how to select more than one from a select menu?

Posted: Wed Jul 31, 2013 3:45 pm
by John Herdean

outstanding issue 2


how to select more than one from a select menu?

Posted: Wed Jul 31, 2013 4:18 pm
by Kateryna Grynko

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?


how to select more than one from a select menu?

Posted: Wed Jul 31, 2013 6:36 pm
by John Herdean

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'


how to select more than one from a select menu?

Posted: Wed Jul 31, 2013 6:47 pm
by John Herdean

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


how to select more than one from a select menu?

Posted: Wed Jul 31, 2013 6:50 pm
by John Herdean

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


how to select more than one from a select menu?

Posted: Wed Jul 31, 2013 7:06 pm
by Kateryna Grynko

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.


how to select more than one from a select menu?

Posted: Wed Jul 31, 2013 8:13 pm
by John Herdean

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


how to select more than one from a select menu?

Posted: Wed Jul 31, 2013 8:58 pm
by John Herdean

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)??


how to select more than one from a select menu?

Posted: Thu Aug 01, 2013 6:29 am
by Maryna Brodina

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


how to select more than one from a select menu?

Posted: Thu Aug 01, 2013 12:38 pm
by John Herdean

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