我一直在關注該解決方案1創建一個下拉列表,更改基於用戶先前選擇的另一個下拉列表中較高的頁面。不過,我不確定什麼,我需要做的選項會一直在這裏開始填充如何根據上一個下拉選擇填充下拉列表SQL
感謝
<?php
mysql_connect('localhost');
mysql_select_db("test");
$result = mysql_query("SELECT * FROM `contents` WHERE `parent` = 0");
echo "<select name='name'>";
while(($data = mysql_fetch_array($result)) !== false)
echo '<option value="', $data['id'],'">', $data['name'],'</option>'
?>
<select onchange="ajaxfunction(this.value)">
<!-- Options would have been initially populated here -->
</select>
<select id="sub">
</select>
<script type="text/javascript"> function ajaxfunction(parent)
{
$.ajax({
url: 'process.php?parent=' + parent;
success: function(data) {
$('#sub option').remove(); //// here sub is the id of second select box
$('#sub').append(data)
}
});
}
</script>
林可能失去了一些東西愚蠢的,但現在我自己看着辦吧。謝謝 – Tom