Advertisement
Guest User

stackoverflow id #29870230

a guest
Apr 25th, 2015
514
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.76 KB | None | 0 0
  1. <?php
  2.     $countries = array(
  3.             0 => 'Norway',
  4.             1 => 'Denmark',
  5.             2 => 'Sweden'
  6.         );
  7. ?>
  8. <html>
  9. <body>
  10.     <script type="text/javascript">
  11.     function removeItem(value) {
  12.         var selObj = document.getElementById("dd2")
  13.         for (var i = 0; i < selObj.length; i++) {
  14.             if (selObj.options[i].value == value ) selObj.remove(i);
  15.         }
  16.     }
  17.     </script>
  18.  
  19.     <select onchange="removeItem(this.value);">
  20.     <?php
  21.     for ($i = 0; $i < count($countries); $i++) {
  22.         echo '<option value="' . strtolower($countries[$i]) . '">' . $countries[$i] . '</option>';
  23.     }
  24.     ?>
  25.     </select>
  26.  
  27.     <select id="dd2">
  28.     <?php
  29.     for ($i = 0; $i < count($countries); $i++) {
  30.         echo '<option value="' . strtolower($countries[$i]) . '">' . $countries[$i] . '</option>';
  31.     }
  32.     ?>
  33.     </select>
  34. </body>
  35. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement