Advertisement
Guest User

Untitled

a guest
Apr 6th, 2016
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3.  
  4. <head>
  5. <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
  6. <meta charset="utf-8" />
  7. <title></title>
  8.  
  9. <style>
  10. .busca {
  11. float:left;
  12. }
  13. .teste{
  14.  
  15. align-items: center; display: flex; flex-direction: row;flex-wrap: wrap;
  16. justify-content: center;
  17.  
  18.  
  19.  
  20.  
  21. }
  22.  
  23.  
  24. </style>
  25. </head>
  26. <body>
  27.  
  28.  
  29. <select id="teste2" >
  30. <option value="1">Guamiranga</option>
  31. <option value="2">Imbituva</option>
  32. <option value=" " selected="selected">Todas</option>
  33.  
  34. </select>
  35.  
  36. <div id="resultadoempre"></div>
  37.  
  38.  
  39.  
  40. <select id="testes" >
  41.         <option value="1" >Tipo1</option>
  42. <option value="2">Tipo2</option>
  43. <option value=" "selected="selected">Todas</option>
  44.     </select>
  45.  
  46.  
  47.  
  48.  
  49.  
  50. <div id="resultado"></div>
  51.  
  52.  
  53.  
  54. <script>
  55.  
  56.  
  57.  
  58. $( "#testes" ).change(function () {
  59. var str = this.value;
  60.  
  61. var url = "http://localhost/site?cidade="+str;
  62. $.getJSON( url, function( data ) {
  63. //console.log(data);
  64.  
  65. $( "#resultado" ).empty();
  66. for (var i = 0; i <data.length; i++) {
  67.  
  68.  
  69. $( "#resultado" ).append('<li>' +data[i]['nome'] + ' é ' + data[i]['tipo'] +'</li> <img src="http://localhost/site/'+data[i]['Imagem']+'">' );
  70.  
  71. }
  72.  
  73.  
  74. });
  75.  
  76. });
  77.  
  78.  
  79. $( "#teste2" ).change(function () {
  80. var cidade2 = this.value;
  81.  
  82. var url = "http://localhost/?cidade_vaga="+cidade2;
  83. var jqxhr2 = $.getJSON( url, function( data ) {
  84.  
  85.  
  86. jqxhr2.fail(function( jqxhr, textStatus, error ) {
  87. var err = textStatus + ", " + error;
  88. console.log( "Request Failed: " + err );
  89. })
  90.  
  91.  
  92.  
  93. $( "#resultadoempre" ).empty();
  94. for (var i = 0; i <data.length; i++) {
  95.  
  96.  
  97.  
  98.  
  99. $( "#resultadoempre" ).append('<div data-role="collapsible"> <h3>'+data[i]['nome']+'</h3><p>'+data[i]['Tipo'] +data[i]['cidade'] + ' </p> <div data-role="collapsible"><h4>Descrição</h4><p>'+data[i]['Descrição']+ ' </p></div> </div>'
  100. );
  101.  
  102.  
  103. }
  104.  
  105.  
  106. });
  107.  
  108. });
  109.  
  110.  
  111.  
  112.  
  113. </script>
  114.  
  115. </body>
  116. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement