2012-04-23 8 views
0

私は、選択ボックスを持っており、それは価値観やclient example選択オプションのエラーが、クライアント側で実行されます

を持っていると私は

<select name="customer_id" id="customer_id"> 
<?php get_customer_list_options(); ?> 
    </select> | 
    <input id="customer_name_from_sel" type="text" /> 

以下のようにしてjqueryのコード

下のサーバーコードを持っています
<script type="text/javascript"> 
    $(document).ready(function(){ 

    $("#customer_id").bind('change', function() { 
     var k = $("#customer_id option:selected").attr("title"); 
     $("#customer_name_from_sel").val(k); 
    }); 

});​ 

</script> 

と機能コード

function get_customer_list_options() { 
    $fquery39 = mysql_query("select User_ID, First_Name, Email_ID from customers"); 

    while($r39 = mysql_fetch_row($fquery39)) { 
     echo "<option value='$r39[0]' title='$r39[1]' >$r39[2]</option>"; 
    } 

} 

私はjsfiddleからコードを実行すると、サーバーページ上で動作していない間、完全に動作します。 そして、私はすでにjqueryライブラリが正常に動作しています。完全な状態です。

title attrの値は、テキストの下customer_name_from_sel

に表示されていないが、HTMLコードの画像出力です。

enter image description here

エラー画像

enter image description here

+3

何が問題なのですか?何かエラーが出ていますか?エラーログを確認しましたか? PHPエラー報告を有効にしましたか? – dm03514

+0

はい! phpとmysqlのエラーは 'on'です。値attr 'title'はテキスト' customer_name_from_sel'に表示されません – Rafee

+0

真剣に各結果に異なる変数名を使用していますか? – ThiefMaster

答えて

0

私はあなたが$("#customer_id option:selected")が正しい要素を取得するかどうかをテストする必要があると思います。そうでない場合は、selectedIndexを使用して、選択したオプションを取得できます。

関連する問題