I am passing an array of values to PHP using a jquery on multiple checkboxes:
echo "<input type='checkbox' class='regularCheckbox' name='color[]' value='".$colorBoxes[color_base1]."' /><font class='similarItemsText'> ".$colorBoxes[color_base1]."</font><br />";
Jquery looks as follows:
jQuery(document).ready(function($) {
$("input:checkbox").change(function() {
if($(this).is(':checked'))
{
var color = [];
color.push($(this).val());
$(".indexMain").load('indexMain.php?color='+color);
}
});
});
And then I am receiving the array in a PHP with a $color = $_GET['color'];. Would this suffice to have the array and use a foreach($color as $value) { to use my multiple values?
instead of using
.load()you should create a.post(), .get(), or .ajax()to send your data. For instance: