62,244
社区成员




private void GetDropList()
{
HttpContext context = HttpContext.Current;
string sql = "select id,type from breakDownReason ";
StringBuilder sb = new StringBuilder();
SqlDataReader dr = DBHelper.GetReader(sql);
while (dr.Read())
{
sb.Append("<option value ='" + dr["id"] + "'>" + dr["type"] + "</option>");
}
context.Response.Write(sb.ToString());
}
#region 根据id加载数据
private void getReason(int id)
{
HttpContext context = HttpContext.Current;
string sql = "SELECT contents FROM breakDownReason where id='" + id + "'";
SqlDataReader dr = DBHelper.GetReader(sql);
string txtContent = "";
while (dr.Read())
{
txtContent = dr["contents"].ToString();
}
context.Response.Write("{\"Content\":\"" + txtContent + "\",\"id\":\"" + id + "\"}");
}
#endregion
window.onload=function()
{
$.ajax({
type: "POST",
dataType: "text",//
url: 'handler.ashx',
data: { action: "getDrop" },
success: function (b) {
$("#dropList").append(b);
}
});
}
//根据ID加载数据
function getReason(id) {
$.ajax({
type: "POST",
dataType: "json",
url: 'handler.ashx',
data: { action: "getReason", Id: id },
success: function (b) {
$("#txtContent").val(b.Content);
$("#hidId").val(b.id);
}
});
}
function getReason(value) {
var value = document.getElementById("dropList").value;
$.ajax({
type: "POST",
dataType: "json",
url: 'handler.ashx',
data: { action: "getReason", id: value },
success: function (b) {
$("#txtContent").val(b.Content);
$("#hidId").val(b.id);
}
});
}
function getReason(value) {
var value = document.getElementById("dropList").value;
$.ajax({
type: "POST",
dataType: "json",
url: 'handler.ashx',
data: { action: "getReason", id: value },
success: function (b) {
$("#txtContent").val(b.Content);
$("#hidId").val(b.id);
}
});
}
可以了 function getReason(value) {
var value = document.getElementById("dropList").value;
$.ajax({
type: "POST",
dataType: "json",
url: 'handler.ashx',
data: { action: "getReason", id: value },
success: function (b) {
$("#txtContent").val(b.Content);
$("#hidId").val(b.id);
}
});
}