Advertisement
Guest User

revised

a guest
May 24th, 2013
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.35 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4.     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5.     <link rel="stylesheet" type="text/css" media="all" href="style.css" />
  6.     <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
  7.     <title>Using jQuery and XML to populate a drop-down box demo</title>
  8.         <script>
  9.         $(document).ready(function(){
  10.             $.ajax({
  11.             type: "GET",
  12.             url: "dropdown.xml",
  13.             dataType: "xml",
  14.             success: function(xml) {
  15.                     var select = $('#mySelect');
  16.                     $(xml).find('menuitem').each(function(){
  17.                     var title = $(this).find('title').text();
  18.                     select.append("<option/><option class='ddheader'>"+title+"</option>");
  19.                     $(this).find('values').each(function(){
  20.                     var value = $(this).find('value')text();
  21.                     select.append("<option class='ddindent' value='"+ $(this).find('text').text() +"'>"+value+"</option>");
  22.                     });
  23.                     select.children(":first").text("please make a selection").attr("selected",true);
  24.                     });
  25.                 }
  26.             });
  27.         });
  28.      </script>
  29. </head>
  30. <body>
  31. <form>
  32.       <select id="mySelect">
  33.               <option>loading</option>
  34.       </select>
  35. </form>
  36. <div id="TextToWrite"></div>
  37.  
  38. </body>
  39. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement