Как я могу отправить данные из этих двух полей и распечатать данные следующим образом?
The way to print:
Color 1, Quantity 6
Color 2, Quantity 1
Color 3, Quantity 1
Color 4, Quantity 1
Может быть другой способ, но я лично посмотрел на это, потому что, выбрав цвет, поле jQuery открывает поле количества. Если он не выбран, он скрыт.
Спасибо!
// Я отправляю данные с этим кодом:
// ### from here i need to take product id ###
<input type="checkbox" name="qty['.$getColorTitle['uniqueID'].']" class="css-checkbox pColor" value="" id="cb-'.$getColorTitle['uniqueID'].'" />
// ### ### ###
<label for="cb-'.$getColorTitle['uniqueID'].'">
<img src="'.$colorFolder.''.$rowColors['image'].'" height="50px" />
<div class="colorsC">
// ### from here i need to take quantity ###
<input type="hidden" name="qty['.$getColorTitle['uniqueID'].']" value="0" style="width: 45px;" class="qtyC" />
// ### ### ###
</div>
</label>
// Я беру данные с этим кодом:
if($_SERVER['REQUEST_METHOD'] == 'POST') {
switch($_POST['action']) {
case 'C':
foreach($_POST['qty'] as $color_id=>$quantity) {
if($quantity > 0) {
$_SESSION['cart'][$_POST['product_id']][$color_id] = $quantity;
} else {
unset($_SESSION['cart'][$_POST['product_id']][$color_id]);
}
}
break;
}
}