0

私は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'].'&nbsp;'.'&nbsp;'.'&nbsp;'. $row['qualification'].   '&nbsp;'.'&nbsp;'.'&nbsp;'
                  .$row['specialization'].'</option>';

              }  

事前にありがとうラムサイ

4

2 に答える 2

0

私は jQuery の専門家ではありませんが、あなたのdoctor_details.phpページでは、

<select> .... </select> 

しばらく前と後?

于 2012-05-30T08:23:43.307 に答える
0

$.ajax() API を呼び出す典型的な方法は、たとえば

 $.ajax({
      type: "POST",
      url: "Default.aspx/GetDate",
      data: "{}",
      contentType: "application/json; charset=utf-8",
      dataType: "json",
      success: function(msg) {
        // Replace the div's content with the page method's return.
        $("#Result").text(msg.d);
      }
    });
于 2012-05-30T09:49:38.107 に答える