My problem is my product's only one size is inserting. But i am wanting which size i will select it should insert. I am new ajax. I think the problem is in ajax so Please guys help me out. enter image description here
<ul id="MOTForm" class="size" >
<h3>Length</h3>
<input class="single-checkbox" type="checkbox" id="sizeid[]" name="sizeid[]" value="M"> <label> M </label>
<input class="single-checkbox" type="checkbox" id="sizeid[]" name="sizeid[]" value="S"> <label> S </label>
<input class="single-checkbox" type="checkbox" id="sizeid[]" name="sizeid[]" value="L"> <label> L </label>
<input class="single-checkbox" type="checkbox" id="sizeid[]" name="sizeid[]" value="XS"> <label> XS </label>
<input class="single-checkbox" type="checkbox" id="sizeid[]" name="sizeid[]" value="XL"> <label> XL </label>
<input class="single-checkbox" type="checkbox" id="sizeid[]" name="sizeid[]" value="XXL"> <label> XXL </label>
<input class="single-checkbox" type="checkbox" id="sizeid[]" name="sizeid[]" value="XXXL"> <label> XXXL </label>
</ul>
/*ADD TO TEMP CARD*/
function add_temp_card(pro_id, pro_price, pro_name)
{
var quantity = document.getElementById("quantity").value;
var sizeid = document.getElementById("sizeid[]").value;
if(quantity == "") { alert("Please Enter Quantity. "); quantity.focus(); return false; }
if(quantity < 1) { alert("Please Enter Quantity Minimum 1 yrd. "); quantity.focus(); return false; }
var xmlRequest = GetXmlHttpObject();
if (xmlRequest == null)
return;
var url = "add_temp_card.php?quantity="+quantity+"&pro_id="+pro_id+"&pro_price="+pro_price+"&sizeid="+sizeid;
var browser=navigator.appName;
if (browser=="Microsoft Internet Explorer")
{
xmlRequest.open("POST",url, true);
}
else
{
xmlRequest.open("GET",url, true);
}
xmlRequest.setRequestHeader("Content-Type", "application/x-www-formurlencoded");
xmlRequest.onreadystatechange =function()
{
if(xmlRequest.readyState==4)
{
HandleAjaxResponse_add_temp_card(xmlRequest, pro_name);
}
};
xmlRequest.send(null);
return false;
}
function HandleAjaxResponse_add_temp_card(xmlRequest, pro_name)
{
var xmlT=xmlRequest.responseText;
var alertmessage = pro_name + " Added to cart.";
//alert(alertmessage);
location.replace("check_out.php");
document.getElementById("add_temp_card").innerHTML=xmlT;
return false;
}
<?php
session_start();
require_once("webcontrol/connect_db.php");
$quantity = $_REQUEST['quantity'];
$pro_id = $_REQUEST['pro_id'];
$pro_price = $_REQUEST['pro_price'];
$size = $_REQUEST['sizeid'];
$date_time = date("F j, Y, g:i a");
$uniq_id = $_SESSION['uniq_id'];
if(!$uniq_id)
{
$uniq_id = time();
$_SESSION['uniq_id'] = $uniq_id;
$q1 = mysql_query("insert into temp_order values('', '', '$uniq_id', '$date_time')");
}
$q2 = mysql_query("select product_qty from temp_details where temp_id = '$uniq_id' and product_id = '$pro_id'");
$r2 = mysql_fetch_array($q2);
$product_qty = $r2[0];
if(!$product_qty)
{
$q3 = mysql_query("insert into temp_details values('$uniq_id', '', '$size', '$pro_id', '$quantity', '$pro_price')");
} else {
$new_product_qty = $product_qty + $quantity;
$q3 = mysql_query("update temp_details set product_qty = '$new_product_qty' where temp_id = '$uniq_id' and product_id = '$pro_id' ");
}
?>
I will be thanked full for help.