我有两个下拉菜单中的一个是&其他的是产品。我想从类别中选择价值,因为我想在产品下拉列表中显示价值。下面从下拉菜单中选择一个值来显示另一个下拉值中的值在php
是我的代码
<!-- <?php
// include('session.php');
?> -->
<?php
mysql_connect('localhost', 'root', '');
mysql_select_db('product_management');
$sql = "SELECT * FROM category";
$result = mysql_query($sql);
$sql1 = "SELECT * FROM category.c INNER JOIN products.p where WHERE category_id.p = '$id' ";
$result1 = mysql_query($sql1);
?>
<!DOCTYPE html>
<html>
<head>
<title>Product Page</title>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-md-12" style="margin-left: 30%;margin-top: 10%;">
<form role="form">
<div class="form-group">
<label>
Category
</label>
<select name='category_type' id="category_type">
<?php
while ($row = mysql_fetch_array($result)) {
echo "<option value='" . $row['category_id'] ."'>" . $row['category_type'] ."</option>";
}
?>
</select>
</div>
<div class="form-group">
<label>
Products
</label>
<select id="products" name="products" required>
<option value=""> -- SELECT -- </option>
<?php
while ($row = mysql_fetch_array($result1)) {
echo "<option value='" . $row['products'] ."'>" . $row['products'] ."</option>";
}
?>
</select>
</div>
<div class="form-group">
<label>
Price
</label>
<input type="text" id="price" name="price" required>
</div>
<div class="form-group">
<label>
Quantity
</label>
<select id="quantity" name="quantity" required>
<option value=""> -- SELECT -- </option>
</select>
</div>
<div class="form-group">
<label for="exampleInputFile">
Upload Image
</label>
<input id="exampleInputFile" type="file" />
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
</div>
如何实现这一目标?我想从下拉菜单中选择一个值来显示另一个下拉值中的值。
你可以通过调用ajax来实现。 – vel
任何示例plz? – Kirataka
http://stackoverflow.com/questions/34961758/change-dropdown-value-when-another-dropdown-selected-in-a-form-using-jquery-aj – vel