Advertisement
Guest User

Untitled

a guest
May 31st, 2014
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.52 KB | None | 0 0
  1. <!doctype html>
  2. <html lang="en">
  3.     <head>
  4.         <meta charset="UTF-8">
  5.         <title>Document</title>
  6.         <script type"text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
  7.         <script type"text/javascript">
  8.             $(document).ready(function(){
  9.                 //Atribui o evento change a select[name=cidade]
  10.                 $("select[name=cidade]").change(function(){
  11.                     //resgatar o cidade selecionada
  12.                     var param = "cidade="+$(this).val();
  13.  
  14.                     //Envia via ajax pra o arquivo representantes.php o código da cidade
  15.                     $.ajax({
  16.                                 type: 'POST',
  17.                                 dataType: 'html',              
  18.                                 url: 'representantes.php',
  19.                                 data: param,
  20.                                 success: function(data) {
  21.                                     //Aqui imprime na div#representantes o valor
  22.                                     //retornado do arquivo representantes;
  23.                                     $("#representantes").html(data);
  24.                                 }
  25.                             });
  26.  
  27.                     });
  28.             });
  29.  
  30.  
  31.            
  32.         </script>
  33.  
  34.     </head>
  35.     <body>
  36.     <!--FORMULÁRIO LISTANDO AS CIDADES COM REPRESENTANTES-->
  37.         <form action="" method="post">
  38.                 Cidade:
  39.                 <select name="cidades">
  40.                     <option value="5">Rio de janeiro</option>      
  41.                     <option value="6">Rio de janeiro</option>      
  42.                 </select>
  43.  
  44.         </form>
  45.         <!-- Aqui irá imprimir os nomes e links dos representantes-->
  46.         <div id="representantes"></div>
  47.  
  48.     </body>
  49. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement