所以我已经学会了如何动态地将元素添加到数组中——删除它们怎么样?
jQuery
$(document).on('change blur', '.roomFac', function () {
var park = $("#park2").val();
var lecturestyle = $("#lecture_style2").val();
var roomstructure = $("#room_structure2").val();
var groupsize = $("#groupSize2").val();
var facilities = "";
$('select[name*=roomFac]').each(function () {
facilities += $(this).val();
facilities += ",";
});
var dataString = 'park=' + park + '&' + 'lecturestyle=' + lecturestyle + '&' +
'roomstructure=' + roomstructure + '&' + 'groupsize=' + groupsize + '&' +
'facilities=' + facilities;
$.ajax({
type: "POST",
url: "process_timetableMon2.php",
data: dataString,
cache: false,
success: function (html) {
$('#mon').html(html);
}
});
});
process_timetableMon2.php
$array = explode(",", $_POST["facilities"]);
for($i = 0; $i < count($array)-2; $i++){
echo $array[$i].'<br>';
}
我在这里上传了一些代码:http: //jsfiddle.net/kfm5b/3/