我正在尝试创建一个多选下拉列表,并使用此插件multiselect创建了一个。我创建了表单:
<form action="test1.php" method="post">
<div class="input select">
<label for="multiselect">Select employee :</label>
<select name="data[]">
<option value="1">Umananda Deva Sarma</option>
<option value="2">Bhabesh Sarmah</option>
<option value="3">Manika Goswami</option>
<option value="4">Mridusmita Buragohain</option>
<option value="5">Chinmayee Nath</option>
<option value="6">Urmila Brahma</option>
<option value="7">Kalindra Barman</option>
<option value="8">Mr.Biman Chandra Gogoi</option>
<option value="255">SHRI PHANIDHAR NATH</option>
<option value="256">RANJAN KR. BORA</option>
<option value="257">BASANTA PHUKAN</option>
<option value="258">BHUSAN CH.HIRA</option>
<option value="259">MRINAL KR.BHUYAN</option>
</select></div> </div>
<input type="submit" />
</form>
但是在我提交表单后选择了多个选项后,var_dump()
会显示data
元素的第一个值!为什么阵列没有生成?
答案 0 :(得分:2)
像这样添加
<select name="data[]" multiple="multiple">
答案 1 :(得分:2)
select标签应具有多个属性,例如
<select multiple="multiple" name="data[]">
答案 2 :(得分:1)
请查看以下代码更改:
<select name="data[]" multiple="multiple">
和
<script src="jquery.multiple.select.js"></script>
<script>
$('select').multipleSelect();
</script>
答案 3 :(得分:1)
试试这段代码......
<head>
<link href="multiple-select.css" rel="stylesheet"/>
</head>
<body>
<form action="test1.php" method="post">
<div class="input select">
<label for="multiselect">Select employee :</label>
<select multiple="multiple" name="data[]">
<option value="1">Umananda Deva Sarma</option>
...
<option value="259">MRINAL KR.BHUYAN</option>
</select>
</div>
<input type="submit" />
</form>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="jquery.multiple.select.js"></script>
<script>
$('select').multipleSelect();
</script>
</body>