maralvic commited on
Commit
8a56229
·
verified ·
1 Parent(s): 191bc6f

Upload 2 files

Browse files
Files changed (2) hide show
  1. index.html +68 -0
  2. mun.php +19 -0
index.html ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="pt-BR">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>Menu de Municípios</title>
6
+ <style>
7
+ .dropdown {
8
+ position: relative;
9
+ display: inline-block;
10
+ }
11
+ .dropdown-btn {
12
+ padding: 10px;
13
+ background: #007bff;
14
+ color: white;
15
+ border: none;
16
+ cursor: pointer;
17
+ }
18
+ .dropdown-content {
19
+ display: none;
20
+ position: absolute;
21
+ background: #f9f9f9;
22
+ min-width: 200px;
23
+ box-shadow: 0 8px 16px rgba(0,0,0,0.2);
24
+ z-index: 1;
25
+ }
26
+ .dropdown:hover .dropdown-content {
27
+ display: block;
28
+ }
29
+ .dropdown-item {
30
+ display: block;
31
+ padding: 10px;
32
+ color: #333;
33
+ text-decoration: none;
34
+ }
35
+ .dropdown-item:hover {
36
+ background: #ddd;
37
+ }
38
+ </style>
39
+ </head>
40
+ <body>
41
+ <div class="dropdown">
42
+ <button class="dropdown-btn">Selecione um Município</button>
43
+ <div id="dropdownMenu" class="dropdown-content"></div>
44
+ </div>
45
+
46
+ <script>
47
+ document.addEventListener('DOMContentLoaded', () => {
48
+ fetch('mun.php')
49
+ .then(response => response.json())
50
+ .then(data => {
51
+ const dropdownMenu = document.getElementById('dropdownMenu');
52
+
53
+ data.forEach(municipio => {
54
+ const link = document.createElement('a');
55
+ link.href = municipio.url;
56
+ link.textContent = `${municipio.nome} - ${municipio.uf}`;
57
+ link.className = 'dropdown-item';
58
+ dropdownMenu.appendChild(link);
59
+ });
60
+ })
61
+ .catch(error => {
62
+ console.error('Erro ao carregar municípios:', error);
63
+ dropdownMenu.innerHTML = '<a class="dropdown-item">Erro ao carregar dados.</a>';
64
+ });
65
+ });
66
+ </script>
67
+ </body>
68
+ </html>
mun.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ header('Content-Type: application/json');
3
+ header('Access-Control-Allow-Origin: https://marcelovicente.prof'); // Permite apenas requisições do seu domínio
4
+
5
+ $municipios = [
6
+ [
7
+ "nome" => "São Paulo",
8
+ "uf" => "SP",
9
+ "url" => "https://www.saopaulo.sp.gov.br"
10
+ ],
11
+ [
12
+ "nome" => "Rio de Janeiro",
13
+ "uf" => "RJ",
14
+ "url" => "https://www.riodejaneiro.rj.gov.br"
15
+ ]
16
+ ];
17
+
18
+ echo json_encode($municipios);
19
+ ?>