Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
Latest commit
53 lines (45 loc) · 1.49 KB
/
Copy pathindex.php
File metadata and controls
53 lines (45 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!DOCTYPE html>
<htmllang="en"dir="ltr">
<head>
<metacharset="utf-8">
<title>Página de testes</title>
<scripttype="text/javascript"src="jquery-3.3.1.min.js"></script>
<scripttype="text/javascript">
$(document).ready(function () {
$.getJSON('estados_cidades.json', function (data) {
varitems= [];
varoptions='<option value="">escolha um estado</option>';
$.each(data, function (key, val) {
options+='<option value="'+val.nome+'">'+val.nome+'</option>';
});
$("#estados").html(options);
$("#estados").change(function () {
varoptions_cidades='';
varstr="";
$("#estados option:selected").each(function () {
str+= $(this).text();
});
$.each(data, function (key, val) {
if(val.nome==str) {
$.each(val.cidades, function (key_city, val_city) {
options_cidades+='<option value="'+val_city+'">'+val_city+'</option>';
});
}
});
$("#cidades").html(options_cidades);
}).change();
});
});
</script>
</head>
<body>
<h1>Testes</h1>
<formclass=""action="index.html"method="post">
<selectid="estados">
<optionvalue=""></option>
</select>
<selectid="cidades">
</select>
</form>
</body>
</html>