# Other Languages > jQuery >  not taking values for shopping cart

## ravi951

hi all,
       i have written a code for simple shopping cart with 4 items.when i selecting the quantity and clicking the add to cart button it is not taking the values.it is displaying the array values what i have given.kindly tell me what is the problem and how to solve it...
below  is my "index.html"



```

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> JavaScript jQuery</title>
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/jquery-1.6.2"></script>

<script type="text/javascript">
    $(document).ready(function() {
    // call the cart function
   $("#sc_cart").smartCart();
  }); 
</script>
<!--<link rel="stylesheet" type="text/css" href="css/cart.css" /> -->
</head>
<body>
 <center><h2>Select Your products</h2></center>
<form  method="post" action="results.php">
 
<div id="smartcart" class="Container">  <!-- open "contanier" class -->         
  <div id="sc_productlist" class="ProductList"> <!-- open "ProductList" class" -->
    
 <div class="ProductListItem">  <!-- open apple Iphone -->
    <table border="0" cellpadding="2" cellspacing="2">
        <tr>
          <td rowspan="3"><img width="100px" src="images/product0.jpg" /></td>
          <td><strong><span id="prod_name100">Apple IPhone 3G</span></strong></td>
        </tr>
        <tr>
         <td><label>Price:</label> $<span id="prod_price100" style="color:red">1450.75</span></td>
        </tr>               
        <tr>
         <td><label>Quantity:</label>
         <input name="prod_qty" class="Text" id="prod_qty100" size="3" type="text">
    <input type="button" rel="100" class="ItemButton Btn" value="Add Product"></td>
        </tr>              
       </table>
    </div>  <!-- close apple iphone -->   
 <hr/> 
 <div class="ProductListItem">    <!-- open icepot -->
       <table border="0" cellpadding="2" cellspacing="2">
         <tr>
            <td rowspan="3"><img width="100px" src="images/product1.jpg" /></td>
            <td><strong><span id="prod_name101">Ice Pot</span></strong></td>
         </tr>
         <tr>
            <td><label>Price:</label> $<span id="prod_price101" style="color:red">10.25</span></td>
         </tr>               
         <tr>
            <td><label>Quantity:</label>
            <input name="prod_qty" class="Text" id="prod_qty101" size="3" type="text">
     <input type="button" rel="101" class="ItemButton Btn" value="Add Product"></td>
         </tr>              
       </table>
    </div>      <!-- close icepot --> 
    <hr/>         
 <div class="ProductListItem">  <!-- open "ProductListItem" style stand -->
        <table border="0" cellpadding="2" cellspacing="2">
         <tr>
            <td rowspan="3"><img width="100px" src="images/product2.jpg" /></td>
             <td><strong><span id="prod_name102">Style Stand</span></strong></td>
         </tr>
         <tr>
            <td><label>Price:</label> $<span id="prod_price102" style="color:red">6.15</span></td>
        </tr>               
         <tr>
           <td><label>Quantity:</label>
            <input name="prod_qty" class="Text" id="prod_qty102" size="3" type="text">
        <input type="button" rel="102" class="ItemButton Btn" value="Add Product"></td>
        </tr>              
        </table>          
 </div>   <!-- close style stand-->
      <hr/>
    <div class="ProductListItem">    <!-- for coffee maker -->
        <table border="0" cellpadding="2" cellspacing="2">
        <tr>
           <td rowspan="3"><img width="100px" src="images/product3.jpg" /></td>
           <td><strong><span id="prod_name103">Coffe Maker</span></strong></td>
        </tr>
        <tr>
          <td><label>Price:</label> $<span id="prod_price103" style="color:red">120.35</span></td>
        </tr>               
        <tr>
           <td><label>Quantity:</label>
            <input name="prod_qty" class="Text" id="prod_qty103" size="3" type="text">
        <input type="button" rel="103" class="ItemButton Btn" value="Add Product"></td>
        </tr>              
        </table>            
 </div>       <!-- close coffee maker -->
      <!-- end "ProductList" class" -->
  
 <!-- cart list-->
<div id="sc_cart" class="Cart">
 <select id="product_list" name="product_list[]" style="display:none;" multiple="multiple">
 </select>               
   <div class="CartListHead">
     <table width='50%'>
      <tr>
        <td width='100px'>Product</td>
        <td width='100px'>Quantity</td>
        <td width='150px'>Amount($)</td>
      </tr>
  </table>
   </div>
            
 <div id="sc_cartlist" class="CartList">
 </div>
        
 <div class="CartListHead">
     <table width='100%'>
     <tr>
          <td><span id="message"></span></td>
          <td width='100px'>Subtotal($):</td>
          <td width='120px'><span id="subtotal"></span></td>
        </tr>
     </table>
 </div>
 </div>
 <br> 
 <input style="width:200px;height:35px;float:right;" type="submit" class="Btn" value="Checkout">
 </div>
 </div>
 </form>
</body>
</html>
```


the array elements given here is displaying in the output.how to remove that one.below is my "results.php"



```
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> JavaScript jQuery</title>
<!-- <link rel="stylesheet" type="text/css" href="css/cart.css" /> -->
</head>
<body>
<center><h2>Selected Products</h2></center>
<div id="sc_cart" style="width:950px;" class="Container"> 
<?php
// creating product array
  $product_array = array("100" =>array('product_id'=>'100', 'product_name'=>'Apple IPhone 3G', 'product_price'=>'1450.75', 'product_img'=>'images/product0.jpg'),
                       "101" =>array('product_id'=>'101', 'product_name'=>'Ice Pot', 'product_price'=>'10.25', 'product_img'=>'images/product1.jpg'),
                       "102" =>array('product_id'=>'102', 'product_name'=>'Style Stand', 'product_price'=>'6.15', 'product_img'=>'images/product2.jpg'),
                       "103" =>array('product_id'=>'103', 'product_name'=>'Coffee Maker', 'product_price'=>'120.35', 'product_img'=>'images/product3.jpg'));
 // get the selected product array
// here we get the selected product_id/quantity combination as an array
$product_list = $_REQUEST['product_list'];
if(!empty($product_list)) 
{
?>
  <div class="CartListHead">
    <table width='100%'>
 <tr>
     <td>&nbsp;&nbsp;Product</td>
     <td width='80px'>Quantity</td>
     <td width='130px'>Amount($)</td>
    </tr></table>
  </div>
<?php  
  $sub_total = 0;
   foreach($product_list as $product)
 {
     $chunks = explode('|',$product);
     $product_id = $chunks[0];
     $product_qty = $chunks[1];
     $product_name = $product_array[$product_id]['product_name'];
     $product_amount = $product_array[$product_id]['product_price']*$product_qty;
    
      $sub_total = $sub_total + $product_amount;
?>
 <div class="CartListHead">
   <table width='100%'>
   <tr>
     <td>&nbsp;&nbsp;<?php echo $product_name; ?></td>
     <td width='80px'><?php echo $product_qty; ?></td>
     <td width='130px'><?php echo $product_amount; ?></td>    
   </tr>
   </table>
 </div>
<?php
  }
?>
<div class="CartListHead">
  <table width='100%'>
   <tr>
     <td><span id="message"></span></td>
      <td width='100px'>Subtotal($):</td>
      <td width='120px'><span id="subtotal"><?php echo $sub_total; ?></span></td>
   </tr> 
  </table>
</div>
   <br>
<form action="index.php" method="post">
<?php
if(isset($product_list))
{
 foreach($product_list as $p_list)
  {
   $prod_options .='<input type="hidden" name="product_list[]" value="'.$p_list.'">';
  }
 echo $prod_options;
}
?>
<input style="width:200px;height:35px;float:left;" type="submit" class="Btn" value="Continue Shopping">
</form>     
<?php    
} 
else 
{ 
echo "<strong>Your Cart is Empty</strong>";
}
?>
</div>
</body>
</html>
```

here too below is my "index.php".....


```
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> JavaScript jQuery </title>
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
  $(document).ready(function() {
    // call the cart function
   $("#sc_cart").smartCart();
  }); 
</script>
<!--<link rel="stylesheet" type="text/css" href="css/cart.css" /> -->
<?php
// creating product array
$product_array = array("100" =>array('product_id'=>'100', 'product_name'=>'Apple IPhone 3G', 'product_price'=>'1450.75', 'product_img'=>'images/product0.jpg'),
                       "101" =>array('product_id'=>'101', 'product_name'=>'Ice Pot', 'product_price'=>'10.25', 'product_img'=>'images/product1.jpg'),
                       "102" =>array('product_id'=>'102', 'product_name'=>'Style Stand', 'product_price'=>'6.15', 'product_img'=>'images/product2.jpg'),
                       "103" =>array('product_id'=>'103', 'product_name'=>'Coffe Maker', 'product_price'=>'120.35', 'product_img'=>'images/product3.jpg'));
// get the product list
$product_list = $_REQUEST['product_list'];
$prod_options ='';
if(isset($product_list)){
  foreach($product_list as $p_list){
    $prod_options .='<option value="'.$p_list.'" SELECTED></option>';
  }
}
?> 
</head>
<body>
<center><h2>Select Your products</h2></center>
<form action="results.php" method="post">
 <div id="smartcart" class="Container">           
   <div id="sc_productlist" class="ProductList">
    <?php 
     foreach($product_array as $p)
   { 
 ?>
  <div class="ProductListItem"> 
    <table border="0" cellpadding="2" cellspacing="2">
      <tr>
        <td rowspan="3"><img width="100px" src="<?php echo $p['product_img']; ?>" /></td>
        <td><strong><span id="prod_name<?php echo $p['product_id']; ?>"><?php echo $p['product_name']; ?></span></strong></td>
      </tr>
       <tr>
         <td><label>Price:</label> $<span id="prod_price<?php echo $p['product_id']; ?>"><? echo $p['product_price']; ?></span></td>
       </tr>               
        <tr>
          <td><label>Quantity:</label>
          <input name="prod_qty" class="scText" id="prod_qty<?php echo $p['product_id']; ?>"  size="3" type="text">
       <input type="button" rel="<?php echo $p['product_id']; ?>" class="ItemButton Btn" value="Add Product"></td>
        </tr>              
    </table>
  </div>  
 <?php 
 } 
 ?>   
  </div>  
<div id="sc_cart" class="Cart">
<select id="product_list" name="product_list[]" style="display:none;" multiple="multiple">
    <?php 
   echo $prod_options; 
 ?>
</select>               
    <div class="CartListHead">
      <table width='100%'>
    <tr>
        <td>&nbsp;&nbsp;Product</td>
        <td width='80px'>Quantity</td>
        <td width='140px'>Amount ($)</td>
       </tr>
   </table>
    </div>
   
   <div id="sc_cartlist" class="CartList">
   </div>
   
  <div class="CartListHead">
    <table width='100%'>
 <tr>
      <td><span id="message"></span></td>
      <td width='100px'>Subtotal ($):</td>
      <td width='120px'><span id="subtotal"></span></td>
    </tr>
 </table>
  </div>
   <br> 
<input style="width:200px;height:35px;float:right;" type="submit" class="Btn" value="Checkout">
</div> 
</div>
</form>
</body>
</html>
```

kindly tell me where went wrong and how to solve it.......

----------

