<script>
$(document).ready(function() {
$("#update_item").change(function (e) {
var update_item = $("#update_item").serialize();
$.post("item.php", {"update_item": update_item}, function (data) {
$('#details').html(data);
});
});
});
</script>
<select name="update_item" multiple="multiple" class="form-control" style="width:59%" id="update_item">
<option value="fff">fffffff</option>
<option value="ffff">Select Supplier</option>
<?php
$result = mysql_query("select * from item");
while ($row = mysql_fetch_array($result)){?>
<option value="<?php echo $row['item_name'];?>"><?php echo $row['item_name'];?></option>
<?php } ?>
</select>
<div id="details">
hii
</div>
当前输出:update_item=fff&update_item=ffff&update_item=fdgdfgjkljklkj
预期输出:fff,ffff,fdgdfgjkljklkj
(内爆值)。
答案 0 :(得分:0)
您应该将HTML变量定义为数组(&#39; update_item []&#39;)然后将其序列化,以便执行以下操作:
var_dump($_POST['update_item'])
将有一个数组数据类型,检查:
<script>
$(document).ready(function() {
$("#update_item").change(function (e) {
$.post("item.php", $(this).serialize(), function (data) {
$('#details').html(data);
});
});
});
</script>
<select name="update_item[]" multiple="multiple" class="form-control" style="width:59%" id="update_item">
<option value="fff">fffffff</option>
<option value="ffff">Select Supplier</option>
<?php
$result = mysql_query("select * from item");
while ($row = mysql_fetch_array($result)){?>
<option value="<?php echo $row['item_name'];?>"><?php echo $row['item_name'];?></option>
<?php } ?>
</select>
<div id="details">
hii
</div>
希望它有所帮助!