-
Notifications
You must be signed in to change notification settings - Fork 0
/
AjaxSample.php
56 lines (49 loc) · 1 KB
/
AjaxSample.php
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
54
55
56
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function loadDoc()
{
var c=document.getElementById("seat_type").value;
const xhttp = new XMLHttpRequest();
xhttp.onload = function()
{
document.getElementById("demo").innerHTML = this.responseText;
}
xhttp.open("GET", "AjxResp.php?v="+c, true);
xhttp.send();
}
</script>
</head>
<body>
<form>
Category <select onchange=" loadDoc();" id="seat_type">
<?php
$con=mysqli_connect("localhost","root","","train");
if($con->connect_errno)
{
echo "Connection error";
}
else
{
$str="select * from train_schedule";
$result=mysqli_query($con,$str);
while($r=mysqli_fetch_row($result))
{
?>
<option value="<?php echo $r[0]; ?>"><?php echo $r[1]; ?></option>
<?php
} }?>
</select>
<br>
<div id="demo">
<select>
<option>...Select...</option>
</select>
</div>
<div id="price">
</div>
<button type="submit" onclick="loadDoc()">Change Content</button>
</form>
</body>
</html>