Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <link rel="stylesheet" type="text/css" media="all" href="style.css" />
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
- <title>Using jQuery and XML to populate a drop-down box demo</title>
- <script>
- $(document).ready(function(){
- $.ajax({
- type: "GET",
- url: "dropdown.xml",
- dataType: "xml",
- success: function(xml) {
- var select = $('#mySelect');
- $(xml).find('menuitem').each(function(){
- var title = $(this).find('title').text();
- select.append("<option/><option class='ddheader'>"+title+"</option>");
- $(this).find('values').each(function(){
- var value = $(this).find('value')text();
- select.append("<option class='ddindent' value='"+ $(this).find('text').text() +"'>"+value+"</option>");
- });
- select.children(":first").text("please make a selection").attr("selected",true);
- });
- }
- });
- });
- </script>
- </head>
- <body>
- <form>
- <select id="mySelect">
- <option>loading</option>
- </select>
- </form>
- <div id="TextToWrite"></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement