I have a dropdown with different options. When you select one option, the text inside the option, this, is shown below the dropdown menu. I do this with this code:
var stadsnat_ar = new Array();
$(".stadsnat_options").change(function() {
stadsnat_ar.push($(".stadsnat_options option:selected").val()); //This value should be used in PHP to get correct data from MySQL
var stadsnat = stadsnat = $(".stadsnat_options option:selected").text(); //show the text
$('#teststat').show().append('<br>' + stadsnat);
});
The whole idea is that you can choose multiple options, and then hit submit, to do a search in MySQL with the options you choosed. As you can see, I assign a array with the values of the options you choosed. How can I make the values in the array, visible to PHP?
I've tried this:
$.ajax({
type: "POST",
url: 'searchengine.php',
data: {stad_value: stadsnat_ar},
success: "",
dataType: "json"
});
Then I do this:
<?php
echo $_POST['stad_value'];
?>
But nothing appears. Anyone?