SHARE
TWEET

Untitled

a guest Mar 19th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <select class="js-example-templating" name="mem1">
  2.             <?php
  3.               $query = "select * from user";
  4.               $query_result = query($query);
  5.             while($row = fetch_array($query_result)) {
  6.                 echo "<option value='{$row['user_id']}'>{$row['user_id']} - {$row['name']}</option>";
  7.             }
  8.             ?>
  9.           </select>
  10.           <br><br>
  11.           <select class="js-example-templating" name="mem2">
  12.             <?php
  13.               $query = "select * from user";
  14.               $query_result = query($query);
  15.             while($row = fetch_array($query_result)) {
  16.                 echo "<option value='{$row['user_id']}'>{$row['user_id']} - {$row['name']}</option>";
  17.             }
  18.             ?>
  19.           </select>
  20.           <br><br>
  21.           <select class="js-example-templating" name="mem3">
  22.             <?php
  23.               $query = "select * from user";
  24.               $query_result = query($query);
  25.             while($row = fetch_array($query_result)) {
  26.                 echo "<option value='{$row['user_id']}'>{$row['user_id']} - {$row['name']}</option>";
  27.             }
  28.             ?>
  29.           </select>
  30.  
  31. function formatState (state) {
  32.   if (!state.id) {
  33.     return state.text;
  34.   }
  35.     var $state = $(
  36.     '<span>' + state.text + '</span>'
  37.   );
  38.   return $state;
  39. };
  40. $(".js-example-templating").select2({
  41.   templateResult: formatState
  42. });
  43. </script>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top