jquery chosen plugin - add display none fields -


i'm using jquery chosen plugin multi select. select looks :

<select data-placeholder="chose friend" class="chosen-select" multiple>      <?php             foreach ($my_friends $key => $value) {              echo '<option class="friend_firstname">'.$value["name"].'</option>';                  }      ?>    </select>    

which works perfectly, plugin returns :

<ul class="chosen-choices">     <li class="search-choice">         <span>john</span>         <a class="search-choice-close" data-option-array-index="1"></a>     </li> </ul> 

my problem add additional information display none have :

<ul class="chosen-choices">     <li class="search-choice">         <span>john</span>         <span style="display:none" id="user_id">678</span>         <a class="search-choice-close" data-option-array-index="1"></a>     </li> </ul> 

and here i'm lost. how can add additional information in display none?

thanks help

if form submit, name attribute should present value submitted. add value option elements

<select name="friend" data-placeholder="chose friend" class="chosen-select" multiple>   <?php        foreach ($my_friends $key => $value) {       echo '<option class="friend_firstname" value="'.$value["id"].'">'.$value["name"].'</option>';             }   ?>   </select>   

if form submitted data submitted in form of array (if multiple items selected chosen).

here sample

$(".chzn-select").chosen();  $('form').on('submit', function(e) {    e.preventdefault();    alert($(this).serialize());  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <link href="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.4.2/chosen.min.css" rel="stylesheet" />  <script src="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.4.2/chosen.jquery.min.js"></script>  <form method="post" action="/echo/json">    <select data-placeholder="choose friend..." class="chzn-select" multiple style="width:350px;" name="friend">      <option value="id1">friend1</option>      <option value="id2">friend2</option>      <option value="id3">friend3</option>    </select>    <input type="submit" value="submit" name="submit" />  </form>


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -