2014-09-05 54 views
3

我有幾個選擇下拉工作很好地與selectize.js。在表單上,​​它顯示它只發送所選的最後一個選項。因此,例如,如果用戶選擇:A,B,C以post var_dump($ _ POST)的形式;只有C出現。其他選擇也是如此。selectize.js不發送所有選擇的選項,但只發送最後一個

我通過文件去和在線而不是搜索能糾正,我相信它的東西實在微不足道,但直到我知道,我不知道:(

將不勝感激任何幫助!謝謝!

+0

你能送我的鏈接 – 2014-09-05 07:07:39

+0

我抄碼上:?http://jsfiddle.net/to0b60pg/希望這可能會給一些線索感謝 – Anx 2014-09-05 07:25:47

+0

請檢查我的答案 – 2014-09-05 07:47:24

回答

5
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> 
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"> 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> 
<script src="http://brianreavis.github.io/selectize.js/js/selectize.js"></script> 



<?php 
if(isset($_POST["save"])){ 
    echo '<pre>'; 
    print_r($_POST); 
    echo '</pre>'; 



} 

?> 

<form action="" method="post"> 
<label>Select Class(s)</label> 
<select multiple id="classname" name="classname[]" required class="form-control"> 
    <option value="1">NUR</option> 
    <option value="2">KG</option> 
    <option value="3">PREP</option> 
    <option value="4">I</option> 
    <option value="5">II</option> 
</select> 
<label>Subjects</label> 
<select multiple id="subjects" name="subjects[]" required class="form-control"> 
    <option value="1">English</option> 
    <option value="2">EVS</option> 
    <option value="3">Maths</option> 
    <option value="4">Science</option> 
    <option value="5">Social</option> 
</select> 
<label>Examinations</label> 
<select multiple="multiple" id="exams" name="exams[]" required="true" class="form-control"> 
    <option value="1">Formative Assessment I</option> 
    <option value="2">Formative Assessment II</option> 
    <option value="3">Formative Assessment III</option> 
    <option value="4">Formative Assessment IV</option> 
    <option value="5">Annual</option> 
</select> 

<input type="submit" name="save" value="save" /> 
</form> 

<script> 
    $(document).ready(function() { 
    $('#exams').selectize({ 
     hideSelected: 'true' 
    }); 

    $('#subjects').selectize({ 
     hideSelected: 'true' 
    }); 

    $('#classname').selectize({ 
     hideSelected: 'true' 
    }); 
}); 

</script> 
+0

感謝僅限Ritesh :)! – Anx 2014-09-05 08:46:33

+0

@Anx歡迎... – 2015-03-31 11:00:15

相關問題