node.js - nodejs express req.session post method -


i'm trying build simple cart in express.

req.session.cart.styles[req.params.a] = {                 "_id":style.id,                 "style":style.style,                 "a":style.a,                 "price":style.price,                 "desc":style.desc,                 "category":style.category,                 "color":style.colors,                 "quantity":1              }; 

and here's json:

"13123": { "style":"13123", "a":"13123", "price":2, "desc":"askfjalsidjfalskdjflasidfjekajlsdkfj", "img":"http://127.0.0.1:8080/views/img/asdf.jpg", "imgs":["a","b","c"], "category":"top", "colors":[{"color":"red","prestock":50,"instock":10,"inactive":0},{"color":"off white","prestock":60,"instock":5,"inactive":0}], "quantity":1}} 

you can see 'colors' array, possible 1 color? if post is, retunrs colors.

ps.

<form method="post" action="/style/cart/add/prestock/{{stylelist.a}}"> <input type="hidden" name="_id" value="_id"> <input type="hidden" name="style" value="style"> <input type="hidden" name="a" value="a"> <input type="hidden" name="price" value="price"> <input type="hidden" name="category" value="category"> <input type="hidden" name="quantity" value="1">       <input class="return" type="checkbox" name="color" value="red"> <input class="return" type="checkbox" name="color" value="off white"> <input class="return" type="checkbox" name="color" value="green"> </form> 

yes, reference array index, followed property:

style.colors[0].color, //returns red json 

Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

java.util.scanner - How to read and add only numbers to array from a text file -

iphone - Three second countdown in cocos2d -