Skip to content

Instantly share code, notes, and snippets.

@vitqst
Last active September 12, 2015 11:57
Show Gist options
  • Save vitqst/4088f0791a376528afde to your computer and use it in GitHub Desktop.
Save vitqst/4088f0791a376528afde to your computer and use it in GitHub Desktop.
<?php
include_once 'dbconfig.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title> test </title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".type").change(function()
{
var type_top = $(this).val();
var dataString = 'type_top='+ type_top;
alert(dataString);
$.ajax({
type: "POST",
url: "type_child.php",
data: dataString,
cache: false,
success: function(html){
$(".type_child").html(html);
}
});
});
});
</script>
</head>
<body>
<center>
<div>
<label> THỂ LOẠI :</label>
<select name="country" class="type">
<option selected="selected">----- Chọn thể loại --</option>
<?php
$query = "SELECT * FROM type" ;
$result = mysqli_query($connection,$query) ;
while($row = mysqli_fetch_array($result) )
{
?>
<option value="<?php echo $row['type_tag']; ?>"><?php echo $row['type_name']; ?></option>
<?php
}
?>
</select>
<br>
<label>THỂ LOẠI CON :</label>
<select name="state" class="type_child">
<option selected="">-- Chọn thể loại con --</option>
</select>
</div>
<br />
</center>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment