Advertisement
Guest User

multiple attribute selector on drop down menu

a guest
Jun 13th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.29 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3.  <head>
  4.   <meta charset="utf-8">
  5.   <title>Testing</title>
  6.   <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.  
  8.   <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
  9.  
  10.   <script>
  11.     $(function() {
  12.      function dropDownSelect() {
  13.       $('#award-type').on('change', function(e) {
  14.        var selectValue = $(this).val();
  15.  
  16.        if (selectValue == 'award1') {
  17.         $('.award-text').show().text("you won award 1");
  18.        } else if (selectValue == 'award2') {
  19.         $('.award-text').show().text("you won award 2");
  20.        } else if (selectValue == 'award3') {
  21.         $('.award-text').show().text("you won award 3");
  22.        } else {
  23.         $('.award-text').show().text(" ");
  24.        }
  25.       });
  26.      }
  27.      $('#award-type').on('change', dropDownSelect).change();
  28.     });
  29.   </script>
  30.  
  31.  </head>
  32.  <body>
  33.  
  34.   <select id="award-type">
  35.    <option value="">choose one</option>
  36.    <option value="award1">Award 1</option>
  37.    <option value="award2">Award 2</option>
  38.    <option value="award3">Award 3</option>
  39.    <option value="award4">Award 4</option>
  40.    <option value="award5">Award 5</option>
  41.    <option value="award6">Award 6</option>
  42.   </select>
  43.   <div class="award-text"></div>
  44.  
  45.  </body>
  46. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement