我有选择框,它有值和 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
customer_name_from_sel
以下是HTML代码的图像输出。
错误图片
答案 0 :(得分:0)
我认为您需要测试$("#customer_id option:selected")
是否获得正确的元素。如果没有,您可以使用selectedIndex
获取所选选项。