我正在汽车经销商网站上工作,客户可以在该网站上发布不同类型的汽车。客户可以在白板或黄板的基础上分类或查看汽车。
我的查询ID: 有一个类别页面,我默认显示所有类型的汽车。但我需要当客户从下降数据中选择任何值时,将根据选择值进行更改。这是下拉代码:
<form action="" method="post" enctype="multipart/form-data">
<div class="b-infoBar__select-one">
<span class="b-infoBar__select-one-title">SORT BY</span>
<select name="cartype" id="cartype" class="m-select">
<option value="" selected="">Select Car Type</option>
<?php
$query=mysql_query("select * from cartype");
while($display=mysql_fetch_array($query))
{
?>
<option value="<?php echo $display['cartype']; ?>"><?php echo $display['cartype']; ?></option>
<?php
}
?>
</select>
</div>
</form>
这是我的数据显示代码:
<div class="row">
<?php
$query=mysql_query("select * from productdetail");
while($display=mysql_fetch_array($query))
{
?>
<div class="col-lg-4 col-md-6 col-xs-12">
<div class="b-items__cell wow zoomInUp" data-wow-delay="0.5s">
<div class="b-items__cars-one-img">
<a href="details.php?id=<?php echo $display['id']; ?>"><img class='img-responsive' src="images/product/<?php echo $display['img']; ?>" width="400" height="300" alt='chevrolet'/></a>
</div>
<div class="b-items__cell-info">
<div class="s-lineDownLeft b-items__cell-info-title">
<a href="details.php?id=<?php echo $display['id']; ?>"><h2 class=""><?php echo $display['companyname']; ?></h2></a>
</div>
<div class="row m-smallPadding">
<div class="col-xs-6">
<ul>
<li><?php echo $display['make']; ?></li>
<li><?php echo $display['model']; ?></li>
<li><?php echo $display['status']; ?></li>
<li><?php echo $display['fueltype']; ?></li>
</ul>
<h5 class="b-items__cell-info-price"><?php echo $display['price']; ?></h5>
</div>
<div class="col-xs-6">
<div class="b-items__cell-info-km">
<img src="assets/icon/meter.png" />
<p><?php echo $display['kilometer']; ?></p>
</div>
<a href="details.php?id=<?php echo $display['id']; ?>" class="btn m-btn">VIEW DETAILS<span class="fa fa-angle-right"></span></a>
</div>
</div>
</div>
</div>
</div>
<?php
}
?>
</div>
答案 0 :(得分:0)
<html>
<body>
<script language="javascript" type="text/javascript">
<!--
//Browser Support Code
function myFunction(){
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
var ajaxDisplay = document.getElementById('ajaxDiv');
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
}
var cartype = document.getElementById("cartype").selectedIndex;
var queryString = "?cartype=" + cartype;
ajaxRequest.open("GET", "your get data page .php" + queryString, true);
ajaxRequest.send(null);
}
//-->
</script>
<form action="" method="post" enctype="multipart/form-data">
<div class="b-infoBar__select-one">
<span class="b-infoBar__select-one-title">SORT BY</span>
<select name="cartype" id="cartype" onchange="myFunction()">
<option value="" selected="">Select Car Type</option>
<!-- <?php
$query=mysql_query("select * from cartype");
/* while($display=mysql_fetch_array($query))*/
{
?> -->
<option value="VOLVO">VOLVO</option>
<!-- <?php
}
?> -->
</select>
</div>
</form>
<div id='ajaxDiv'>Your result will display here</div>
</body>
</html>