-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathindex.php
More file actions
40 lines (36 loc) · 966 Bytes
/
index.php
File metadata and controls
40 lines (36 loc) · 966 Bytes
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
<?php
// author: sofish, https://github.com/sofish
// licensed under: MIT
?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>天气信息</title>
</head>
<body>
<iframe id="weather" src="javascript:void(0)" frameborder="0" width="160" height="20" scrolling="no"></iframe>
<select id="changecity">
<?php include dirname(__FILE__) . '/weather_code.php';
foreach($weather_code as $city => $code) { ?>
<option value="<?= $city ?>"><?= $city ?></option>
<? } ?>
</select>
<script type="text/javascript">
~function(){
var $ = function(id) {
return document.getElementById(id);
},
changeCity =$('changecity'),
weather = $('weather'),
applySrc = function(city){
return weather.src = './weather.php?city=' + encodeURIComponent(city);
};
applySrc(changeCity.value);
changeCity.onchange = function(){
applySrc(changeCity.value);
}
}()
</script>
</body>
</html>