0

I am having a problem on finding how to make simpleCart js work with both checkbox and select. I have builded a sample of a code below. As you can see the problem is that if we check the checkbox, it will put in cart one item with bar on foo and small on test. We unckeck it and press add, it will put an item with only test=small. If we check again the foo checkbox and we press add, it will update the one without the bar, where it should update the one with the bar.

Thank you for your help and excuse me for my bad english.

JsFiddle

1 Answers1

0

<select class="item_test">...</select> and <label> <input type="checkbox"...></label> are two different elements, and when you press 'add to cart' it adds two values from <select> and from <input type="checkbox"../>. So if you want to do a "Blank" input in a checkbox menu you should do something like this <option value="" selected="selected">Make a choice</option>

MakeLoveNotWar
  • 956
  • 9
  • 25
  • Hello mandeep, i tryed you answer but it seems that it does not work propertly. You see if i check the foo i get it correctly. If i still have the foo checked and i select a size (ex. small) i dont get a new item with small and the bar, but it adds an item to the previous one. http://jsfiddle.net/xdanaskos/2A3MW/8/ – user3193190 Jan 20 '14 at 12:13
  • i get it. if i check the foo and add it to the cart it will add all correctly(all sizes)if i uncheck it and then check it again it will not add sizes, but it will add the product to the unchecked row. it need to be updated...and what exactly do you want to do, again? it seems to work fine – MakeLoveNotWar Jan 20 '14 at 12:31
  • the 'radio' must be updated after changing('beforeAdd'ing to the cart)...and what exactly do you want to do, again? – MakeLoveNotWar Jan 20 '14 at 12:37
  • If i choose a product with foo unchecked and a size and then i add an item with the foo checked and the same size, it will update the previous one (the one without the foo). I want to add a new item and not update the previous one, becauze the second one will not have the foo bar. – user3193190 Jan 20 '14 at 13:01
  • hmm...http://jsfiddle.net/xdanaskos/2A3MW/8/ Still got the problem,but mb you can check 'beforeAdd' if radio button unchecked show error or something – MakeLoveNotWar Jan 20 '14 at 13:47