2013-10-07 2 views
0

나는 익스프레스에서 간단한 카트를 만들려고 노력하고있다.nodejs express req.session 게시 방법

"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}} 

당신은 '색상'배열이라고 볼 수는 하나 개의 색상을 얻을 수 있습니다 :

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 
      }; 

여기 내 JSON입니까? 내가 이것을 게시하는 경우, 그것은 모든 색상을 retunrs.

ps. 다수의 체크 박스가 선택 될 때까지 선택된 경우

style.colors[0].color, //returns red from your JSON 
+0

것이 가능하므로 여러 값이 반환 될 것이다

<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> 
user568109

+0

여러 값이 반환되기를 원합니다 ... 감사합니다. – wisleans

+0

나를 도와 줄 수 있습니까? – wisleans

답변

0

예, 건물 뒤에 배열 인덱스를 참조. 확인란이나 라디오 버튼을 원하십니까?
+0

고마워! 나는 단지 이것을 시도했지만 운이 없었습니다. – wisleans

+0

그래요. http://jsfiddle.net/nLn6n/ @wisleans – tymeJV

+0

오, 그것은 피들에서 작동합니다! 하지만 내가 확인한 모든 색상을 얻고 싶다면 어떻게해야할까요? – wisleans