1
我有一個名爲作物和各種 .The 各種選擇框通過Ajax加載選擇框取決於作物的選擇,然後呈現給JQueryMobile,填充correctly.but所選值的值不顯示。JQuery Mobile選擇框不顯示選定的值?
原因是什麼?
我的代碼:
<script>
$(document).ready(function() {
$("#crop").change(function(){
$.ajax({
type:'GET',
url :'variety.php',
dataType:"json",
//data:"fname=me",
data: ({crop: $('#crop').val()}),
success : function(data){
// alert(data);
$("#variety").html(data);
},
error : function(data){
// alert("Error"+data);
}
});
});
});
</script>
<div data-role="fieldcontain">
<label for="crop" class="select">Crop :</label>
<select name="crop" id="crop" data-native-menu="false"><option selected>Choose an option</option>
<?php
while ($res = mysql_fetch_assoc($tests)) {
$dropdown .= "\r\n<option value='{$res['id']}'>{$res['crop_name']}</option>";
}
echo $dropdown;
//}
?>
</select>
</div>
<div data-role="fieldcontain">
<label for="variety" class="select">Variety :</label>
<select name="variety" id="variety" data-placeholder="true">
</select>
</div>
<?php
}
?>
其工作......謝謝@Aaron – Jishin
很高興聽到它。幾周前,幾乎同樣的問題讓我感到沮喪,除了單選按鈕。 – Aaron
+1節省我的時間。 – neeraj