我從下拉菜單中選擇一個列表。下拉列表選擇從數據庫中獲取值,然後將字符串值coudn't分配給文本框。如何將下拉列表更改爲文本框的值
我控制器
[HttpPost]
public ActionResult GetCountryBasedCharge(Int64 ID)
{
OrderBilling objOrderBilling = new OrderBilling();
OrderBilling objCalculate = new OrderBilling();
objCalculate = objOrderBilling.AutoCompleteState(ID);
string chargeid =Convert.ToString(objCalculate.ShippingCharge);
return Content(chargeid);
}
我查看
@Html.DropDownList("Country", (IEnumerable<SelectListItem>)ViewBag.countrytitles,
"-----------Select----------"
, new { id = "txtBCountry", @class = "selectStyle" })</td><td><label style="color:red" >*</label>
<input type="text" class="textbox" id="txtChargeAmts" />
<script type="text/javascript" >
$(document).ready(function() {
var CountryID;
$(function() {
$("#txtBCountry").change(function() {
CountryID = $("#txtBCountry option:selected").val();
$.ajax({
type: "POST",
url: '../Billing/GetCountryBasedCharge',
data: { ID: CountryID },
success: function (data) {
if (data) {
alert(data);
**$('#txtChargeAmts').html(data);**
}
}
});
});
});
</script>
感謝迪安娜.. – Raja 2013-02-15 11:38:38