我得到了这个Bootstrap Multiselect Dropdown文件,它在HTML中显示得很好。但我的问题是我如何捕获PHP中的选定选项
这是HTML
<html>
<head>
<title>Multiselect</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<link href="css/bootstrap.min.css" rel="stylesheet">
<link rel="shortcut icon" href="favicon.ico">
<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<link href="css/bootstrap-multiselect.css"
rel="stylesheet" type="text/css" />
<script src="js/bootstrap-multiselect.js"
type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$('#lstFruits').multiselect({
includeSelectAllOption: true
});
$('#btnSelected').click(function () {
var selected = $("#lstFruits option:selected");
var message = "";
selected.each(function () {
message += $(this).text() + " " + $(this).val() + "\n";
});
alert(message);
});
});
</script>
</head>
<body>
<tr>
<td colspan="2" align="right">
<form>
<select id="lstFruits" multiple="multiple" name="fruits">
<option value="1">Lemon</option>
<option value="2">Apple</option>
<option value="3">Banana</option>
<option value="4">Guava</option>
<option value="5">Orange</option>
</select>
<button type="submit" class="btn btn-default" name="create_class">Create</button>
</form>
</td>
</tr>
</body>
然后在PHP中捕获选项,我做了
if (array_key_exists(create_fruits, $_POST)) {
echo $_POST['fruits'];
}
但什么都没发生。拜托,我该怎么办?