javascript - how to read complex cookie data - jquery cookie -


i have got read , manipulate cookie looks this:

cookiename = 9918430821007~12.00 | 7c9918430831006~3.00 | 7c7501031311309~50.30 

the above cookie has 3 values, each separated "|" each value separated "~"

the first item(9918430821007) represents unique product id second (12.00) represents amount in usd

i stuck in following:

how check if product id exist when adding product shopping cart(to prevent duplicate entries)?

i have got make total $ of usd values, how make total of these amout pairs (12.00,3.00,50.30..etc)

fyi using jquery 1.72 + jquery.cookie.js

any appreciated

thanks

how ?

var products = $.cookie('cookiename').split(' | ') // products= ['9918430821007~12.00', '7c9918430831006~3.00', '7c7501031311309~50.30'] 

you this:

products[0].split('~')[0] // 9918430821007 products[0].split('~')[1] // 12.00 

...or of sort. hope helps!

edit here's jsfiddle help


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -