javascript - LocalStorage button & list -
i'm pretty new javascript.
i need "add favorites/remove favorites" function on several products pages. function save product id , put in array.
and then, need write page retrieve products id's localstorage in order display them mysql select.
i've got mysql part covered can me bit javascript?
thanks.
for example can declare array of ids
var favourites = new array();
then in code should add items array
favourites.push('file1_id') favourites.push('file2_id')
at end save localstorage (stringify array json, have store strings in localstorage)
localstorage.setitem('favourites', json.stringify(favourites))
on page sql query can saved ids localstorage (parse json original array)
json.parse(localstorage.getitem('favourites'))
Comments
Post a Comment