Ok I have been fighting this for quite a while and it has been really irritating. So I need some help.
I have a drop down that allows the user to select a size for the picture they are purchasing. This value needs to saved in a php session and assigned to that particular picture, allowing the user to choose multiple pictures with a different size on each picture.
I am submitting the drop down through ajax when the user selects the size:
<script type="text/javascript">
$('#sizeConfirm').click(function() {
var size = $("#sizeSelector option:selected").val();
var id = $("#idInput").val();
$("#sizeId"+id).html(size);
var dataString = 'size='+ size + '&id='+id;
$.ajax({
type:"POST",
url: "../functions/size-functions.php",
data: dataString,
success: function() {
}
})
})
</script>
And this submits to the following script:
<?php
session_start();
$id = $_POST['id'];
$_SESSION['size'][$id] = $_POST['size'];
?>
I have used the set up in the code above for adding the pictures to the shopping cart. I placed: <?php echo $_SESSION['size']; ?>
on the same page the java script is placed and I receive: Array
as a result of that.
What am I doing wrong? Can someone help me out?
Basically, I want to be able to do the following:
User selects Category -- This works
User selects Picture -- This works
User select size on cart page -- This is what the question is about.
If it helps the select option looks like this:
<select class="form-control" id="sizeSelector">
<option>Select a Size</option>
<option>4x4</option>
<option>4x6</option>
<option>5x7</option>
<option>6x6</option>
<option>8x8</option>
<option>8x10</option>
<option>8x12</option>
<option>10x12</option>
<option>12x16</option>
<option>4x18</option>
</select>
I wasn't sure exactly what to put in this question -- So if you believe I am missing something that would require the solution to be found, simply comment and tell me and I will add it. Thank you!