I have two dropdowns where ajax gets the value from it and send to my page calculates.php and then i will get a result based on both dropdown selection. But its not working well. The problem is that im getting a error that is saying
Notice: Undefined index: icms in C:\xampp\htdocs\system\clientes\gallery\cart.php on line 159
Notice: Undefined index: icms in C:\xampp\htdocs\system\clientes\gallery\cart.php on line 160
icms is a variable that holds the $_SESSION['icms']. When i get the result i must store in session and get data from data base. I dont know why i am getting this. And my values are not returning.
my script
$(document).ready(function(e){
e.preventDefault();
$('.fabric').on('change',function(e){
var fabricID = $(this).val();
console.log("fabric id_price is " + fabricID); //debugging
if(fabricID){
$.ajax({
type:'GET',
url:'calculates.php',
data:'id_price='+fabricID,
success:function(html){
// do nothing cuz i just need to combine with script bellow
//some closing tags
$('.size').on('change',function(e){
e.preventDefault();
var sizeID = $(this).val();
if(sizeID){
$.ajax({
type:'GET',
url:'calculates.php',
dataType: 'json',
data:'size_id='+sizeID,
success:function(html){
$(".icms" + id).text(data.val);
//some closing tags
this is where i get my dropdown data and search database... calculates.php
// this is calculates.php
header('Content-Type: application/json');
include_once '../incluedes/conn_cms.php';
if(isset($_GET["size_id"],$_GET["id_price"])){
$the_size=$_GET["size_id"] ;
$the_id_price=$_GET["id_price"] ;
$query3 = "SELECT * FROM valores_almofadas
WHERE size='$the_size'
AND price_id ='$the_id_price'";
$result = mysqli_query($conn,$query3);
while($rows = mysqli_fetch_assoc($result)){
if($_SESSION['estado'] == 'SP'){
$ICMS = $rows['icms_7'];
}else{
$ICMS = $rows['icms_12'];
}
$_SESSION['icms']=$ICMS;
} echo $_SESSION['icms'];
}
and here where i am supouse to receive data from the result. this below is my cart.php script
$value
holds quantity and the $id
holds the product row id.
159 <td class="icms'.$id.'">R$:'.$_SESSION['icms'] .'</td>
160 <td class="total'.$id.'">'.$value * $_SESSION['icms'] .' </td>