Page 1 of 1

Saving Local Storage Variable from Select Menu

Posted: Tue Aug 13, 2013 6:39 am
by Chris Whitfield

Hello,

In order to do so, should i create an event on click to run javascript?

I currently have the following JS where 'testselectcomponent' is the name of my component.

var value = Appery('testselectcomponent').val();
localStorage.setItem('CityFilter', value);

Am i doing something wrong?

Thanks


Saving Local Storage Variable from Select Menu

Posted: Tue Aug 13, 2013 8:55 am
by Maryna Brodina

Hello! This code works for me. Please check are there any errors in console.


Saving Local Storage Variable from Select Menu

Posted: Thu Aug 15, 2013 5:07 am
by Chris Whitfield

Hi Marina,

Thanks for the reply. I've been wracking my brain with no luck on getting this working.

I've tried again tonight and noticed that the select component allows you to create an event on click to store a local variable which i can bind to the component with the property name being "selected".

Ive basically created two select components and on the filter results page I have the following JS in "where" for request.

return '{ $and: [ { "RestaurantType": "' + localStorage.getItem("restaurantTypeFilter") + '" }, { "NearestTourismCity": "' + localStorage.getItem("nearesttourismcity") + '" } ] }';

Is this is correct?


Saving Local Storage Variable from Select Menu

Posted: Thu Aug 15, 2013 5:07 am
by Chris Whitfield

I meant to ask, what i've done above doesn't work... but is the direction correct?


Saving Local Storage Variable from Select Menu

Posted: Thu Aug 15, 2013 6:31 am
by Maryna Brodina

Hi, please check first if there're any errors in console and let us know.
http://docs.appery.io/getting-help/


Saving Local Storage Variable from Select Menu

Posted: Fri Aug 16, 2013 5:46 pm
by Chris Whitfield

Hey Marina!

I got it to work... i needed to change it to on "value change" to store the local variable.. and yes the JS did work.

I suppose i have another issue now which is that I have 5 select menus on one page and the $and JS for "where".. I want the user to be able to refine their search results as they wish but i want the default on each select menu to be selecting all the values in the database. This way they can mix and match as they choose.

If I make the selected option label "Choose All", then what would i put for the Value?

Would i need to amend the JS for Where?

Thanks in advance


Saving Local Storage Variable from Select Menu

Posted: Fri Aug 16, 2013 7:17 pm
by Kateryna Grynko

Hi Chris,

If you select "Choose All" for some parameter then you would need to exclude this parameter from "where" query.