selectize.js not sending all selected option but only the last one
Asked Answered
N

1

5

I have few select dropdown working nicely with selectize.js. On form post, it appears it only send the last option selected. So for example, if the user select's: A, B, C in the form post var_dump($_POST); only C appears. Same is the case with other select.

I went through the documentation and searched online but not able to rectify, I am sure its something really trivial but till I know, I don't know :(

Would greatly appreciate any help! Thank you!

Noetic answered 5/9, 2014 at 7:6 Comment(2)
can you send me the link?Zendejas
I have copied the code on: jsfiddle.net/to0b60pg Hope this might give some clues. ThanksNoetic
Z
11
<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>
Zendejas answered 5/9, 2014 at 7:46 Comment(1)
@E-housmaMardini WelcomeZendejas

© 2022 - 2024 — McMap. All rights reserved.