私は2つの選択ボックスを持っています。firstbox で選択した値に基づいて、secondbox の値が mysql データベースから取り込まれます。私はよくグーグルしますが、答えが見つかりませんでした。誰かが私に提案/解決策を教えてくれます。
私のコード: 最初の選択ボックス:
<select name="specialities" id="specialities">
<option value="select">-------select-------</option>
<option value="psychiatry">psychiatry</option>
<option value="sleep">sleep</option>
<option value="nuerology">nuerology</option>
<option value="pulmonary">pulmonary</option>
<option value="git">git</option>
<option value="general">general</option>
<option value="ent">ent</option>
<option value="cvs">cvs</option>
<option value="breast">breast</option>
<option value="reproductive_male">reproductive_male</option>
<option value="reproductive_female">reproductive_female</option>
</select>
これは、データが db から読み込まれる div です。
<div>
<select id="main">
<option>----------------------------</option>
</select>
</div>
選択ボックスの人口のための私のjqueryコード:
<script>
$(document).ready(function() {
$("#specialities").change(function(){
var spl = $(this).val();
$.ajax(
"doctor_details.php",
{spl : "spl"},
function(data) {
$('#main').html(data);
});
</script>
私のphpページのdoctor_details.php:
$sql = "select * from doc_work_details where specalities='$_REQUEST[spl]'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
echo '<option>'.$row['firstname'].' '.' '.' '. $row['qualification']. ' '.' '.' '
.$row['specialization'].'</option>';
}
事前にありがとうラムサイ